7 * Copyright (C) 2015 Ensoftek, Inc
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
22 * @link http://www.open-emr.org
25 require_once("../interface/globals.php");
26 require_once("../ccr/uuid.php");
27 require_once("../library/patient.inc.php");
28 require_once "../library/options.inc.php";
29 require_once("../library/clinical_rules.php");
30 require_once "$srcdir/report_database.inc.php";
31 require_once "qrda_functions.php";
33 use OpenEMR\Common\Csrf\CsrfUtils
;
34 use OpenEMR\Core\Header
;
35 use OpenEMR\Services\FacilityService
;
37 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
38 CsrfUtils
::csrfNotVerified();
41 $facilityService = new FacilityService();
43 //Remove time limit, since script can take many minutes
46 //DENEXCEP NOT NEEDED rules
47 $denExcepNotNeedRules = array('0002', '0018', '0024', '0038', '0043', '0059', '0421');
49 //Predefined QRDA HQMF ID's for CQM rules
50 $preDefinedUniqIDRules = array();
51 $preDefPopIdArr = array();
53 // CMS147v4/0041 - Preventive Care and Screening: Influenza Immunization HQMF ID: 40280381-4600-425F-0146-EE66F0005509
54 $preDefinedUniqIDRules['0041'] = '40280381-4600-425F-0146-EE66F0005509';
55 $preDefPopIdArr['0041']['IPP'] = 'F48702E6-D39A-49D8-BE3C-8FAB5C6AADDA';
56 $preDefPopIdArr['0041']['DENOM'] = 'B61EC2DC-0841-4906-A84B-5BE5024DA7F1';
57 $preDefPopIdArr['0041']['NUMER'] = '0ED7B212-369B-489A-A5B5-07BC146FA557';
58 $preDefPopIdArr['0041']['DENEXCEP'] = 'B5C9EC50-3011-43DC-AD07-CED2D3B770B2';
60 // CMS122v3/0059 - Diabetes: Hemoglobin A1c Poor Control: HQMF_ID: 40280381-4555-E1C1-0145-90AC70DE2C73
61 $preDefinedUniqIDRules['0059'] = '40280381-4555-E1C1-0145-90AC70DE2C73';
62 $preDefPopIdArr['0059']['IPP'] = 'EDED90E9-E4FE-47E6-90AC-29D9AA3E861A';
63 $preDefPopIdArr['0059']['DENOM'] = '6721D6DA-E87D-4E42-A34A-C8490686598C';
64 $preDefPopIdArr['0059']['NUMER'] = '7549BA9E-1841-4231-8CAA-095BDF0AB8A1';
67 //CMS139v3/0101 - Falls: Screening for Future Fall Risk: HQMF_ID: 40280381-4555-E1C1-0145-672613970D15
68 $preDefinedUniqIDRules['0101'] = '40280381-4555-E1C1-0145-672613970D15';
69 $preDefPopIdArr['0101']['IPP'] = '2448B0C6-6848-4DCB-AA6D-F199337A2C5C';
70 $preDefPopIdArr['0101']['DENOM'] = 'EC400908-35BE-439B-92A9-231D99CEA9DF';
71 $preDefPopIdArr['0101']['NUMER'] = '663FB12B-0FF4-49AB-80A3-624C5E7DF892';
72 $preDefPopIdArr['0101']['DENEXCEP'] = 'FEC7251A-BF8D-4472-97D8-E2A9C0A42176';
74 //CMS127v3/0043 - Pneumonia Vaccination Status for Older Adults: HQMF_ID: 40280381-4555-E1C1-0145-762578A81C4C
75 $preDefinedUniqIDRules['0043'] = '40280381-4555-E1C1-0145-762578A81C4C';
76 $preDefPopIdArr['0043']['IPP'] = '873AECC7-E15B-49E7-8391-D73A46201E2E';
77 $preDefPopIdArr['0043']['DENOM'] = 'FF7016E1-E8C7-43BA-9D56-2BEF649F36FA';
78 $preDefPopIdArr['0043']['NUMER'] = '201F5A6E-4DDE-43A2-BDFC-CE85A98560DA';
80 //CMS69v3/0421 - Preventive Care and Screening: Body Mass Index (BMI) Screening and Follow-Up Plan: HQMF_ID: 40280381-4555-E1C1-0145-D2B36DBB3FE6
81 $preDefinedUniqIDRules['0421']['Numerator 1'] = '40280381-4555-E1C1-0145-D2B36DBB3FE6';
82 $preDefPopIdArr['0421']['Numerator 1']['IPP'] = '1C936855-E644-44C0-B264-49A28756FDB1';
83 $preDefPopIdArr['0421']['Numerator 1']['DENOM'] = '27F1591C-2060-462C-B5D7-7FE86A44B534';
84 $preDefPopIdArr['0421']['Numerator 1']['DENEX'] = '9B0C3C26-D621-4EA3-81FB-A839A3012044';
85 $preDefPopIdArr['0421']['Numerator 1']['NUMER'] = '3095531C-24D7-4AFB-9BCB-F1901FF0FF69';
87 $preDefinedUniqIDRules['0421']['Numerator 2'] = '40280381-4555-E1C1-0145-D2B36DBB3FE6';
88 $preDefPopIdArr['0421']['Numerator 2']['IPP'] = '6E701B1C-6CA5-4AD5-98C9-5F766745EA89';
89 $preDefPopIdArr['0421']['Numerator 2']['DENOM'] = 'E4DC29B8-EB26-4A01-ABB0-4F99FC03BA39';
90 $preDefPopIdArr['0421']['Numerator 2']['DENEX'] = 'BB1B4301-C275-4BAC-87C9-6E960B1601DA';
91 $preDefPopIdArr['0421']['Numerator 2']['NUMER'] = '7669026D-3683-44CC-A2C5-3D62EB2F8A33';
93 //CMS117v3/0038 - Childhood Immunization Status: HQMF_ID: 40280381-4555-E1C1-0145-D7C003364261
94 $preDefinedUniqIDRules['0038'] = '40280381-4555-E1C1-0145-D7C003364261';
95 $preDefPopIdArr['0038']['IPP'] = '6ED6A787-C871-49B9-825C-70A0DB898977';
96 $preDefPopIdArr['0038']['DENOM'] = '545DA813-89ED-4DCD-BDDF-4B33D93DCD84';
97 $preDefPopIdArr['0038']['NUMER'] = '00193FC7-AEE4-4507-A20F-D25A7BB214AD';
99 //CMS138v3/0028 - Preventive Care and Screening: Tobacco Use: Screening and Cessation Intervention: HQMF_ID: 40280381-4600-425F-0146-1F5867D40E82
100 $preDefinedUniqIDRules['0028'] = '40280381-4600-425F-0146-1F5867D40E82';
101 $preDefPopIdArr['0028']['IPP'] = '4E118B62-2AF8-4F51-9355-6FD3F2427D9F';
102 $preDefPopIdArr['0028']['DENOM'] = 'FA1B3953-AE58-4541-BF7B-84D0EB1B0713';
103 $preDefPopIdArr['0028']['NUMER'] = '35B1A6DF-1871-4633-A74B-BCAE371BC030';
104 $preDefPopIdArr['0028']['DENEXCEP'] = '3EE6DFF5-AB17-482F-A147-E6D1E46DBB79';
106 //CMS157v3/0384 - Oncology: Medical and Radiation – Pain Intensity Quantified: HQMF_ID: 40280381-4600-425F-0146-1F620BDF0EB0
107 $preDefinedUniqIDRules['0384'] = '40280381-4600-425F-0146-1F620BDF0EB0';
108 $preDefPopIdArr['0384']['IPP'] = 'C29B6555-3BC7-416F-B61A-FCACD637594F';
109 $preDefPopIdArr['0384']['DENOM'] = 'E5F80C25-6816-4992-92E2-A735B17F8D4F';
110 $preDefPopIdArr['0384']['NUMER'] = 'C948D0D2-D6E9-4099-9CD4-870F2F83A14C';
112 //CMS146v3/0002 - Appropriate Testing for Children with Pharyngitis: HQMF_ID: 40280381-4600-425F-0146-1F6E280C0F09
113 $preDefinedUniqIDRules['0002'] = '40280381-4600-425F-0146-1F6E280C0F09';
114 $preDefPopIdArr['0002']['IPP'] = '9D1135EA-BA90-45E7-8EED-F7335D1CC934';
115 $preDefPopIdArr['0002']['DENOM'] = 'D04EFECB-A901-4565-BDDB-826510499092';
116 $preDefPopIdArr['0002']['NUMER'] = '3F4CDE57-1C5C-4250-A338-55FED6775F57';
117 $preDefPopIdArr['0002']['DENEX'] = '0525FBA2-F068-4706-ADB5-E345852DC55B';
119 //CMS165v3/0018 - Controlling High Blood Pressure: HQMF_ID: 40280381-4600-425F-0146-1F6F722B0F17
120 $preDefinedUniqIDRules['0018'] = '40280381-4600-425F-0146-1F6F722B0F17';
121 $preDefPopIdArr['0018']['IPP'] = 'A72855CE-3C60-41F9-AEE2-64D4F584DDD4';
122 $preDefPopIdArr['0018']['DENOM'] = '26046A5C-E2CC-4A27-B480-FF7E3575691F';
123 $preDefPopIdArr['0018']['NUMER'] = '0899A359-0CD8-4977-AA29-666892AA3AD4';
124 $preDefPopIdArr['0018']['DENEX'] = '4327D845-6194-410D-A48D-D6E1802CAD55';
126 //CMS155v3/0024 - Weight Assessment and Counseling for Nutrition and Physical Activity for Children and Adolescents: HQMF_ID: 40280381-4555-E1C1-0145-85C7311720F5
127 $preDefinedUniqIDRules['0024']['Population Criteria 1']['Numerator 1'] = '40280381-4555-E1C1-0145-85C7311720F5';
128 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 1']['IPP'] = '10127790-AE94-4070-9DD3-1D3776D08D7C';
129 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 1']['DENOM'] = '3B3C1568-F875-49B1-9090-E2F494EECBB6';
130 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 1']['DENEX'] = 'B288D5A4-D573-4FAA-92D6-0B01E1B35C7A';
131 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 1']['NUMER'] = 'FD4649BD-B962-4CBE-BF4A-C2F95F3EA08E';
133 $preDefinedUniqIDRules['0024']['Population Criteria 1']['Numerator 2'] = '40280381-4555-E1C1-0145-85C7311720F5';
134 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 2']['IPP'] = '10127790-AE94-4070-9DD3-1D3776D08D7C';
135 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 2']['DENOM'] = '3B3C1568-F875-49B1-9090-E2F494EECBB6';
136 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 2']['DENEX'] = 'B288D5A4-D573-4FAA-92D6-0B01E1B35C7A';
137 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 2']['NUMER'] = '52FBD726-4DD1-48F5-98B9-7175754923E1';
139 $preDefinedUniqIDRules['0024']['Population Criteria 1']['Numerator 3'] = '40280381-4555-E1C1-0145-85C7311720F5';
140 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 3']['IPP'] = '10127790-AE94-4070-9DD3-1D3776D08D7C';
141 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 3']['DENOM'] = '3B3C1568-F875-49B1-9090-E2F494EECBB6';
142 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 3']['DENEX'] = 'B288D5A4-D573-4FAA-92D6-0B01E1B35C7A';
143 $preDefPopIdArr['0024']['Population Criteria 1']['Numerator 3']['NUMER'] = 'C43CE779-C5EE-4C15-A4CC-AF1C446CFB09';
145 $preDefinedUniqIDRules['0024']['Population Criteria 2']['Numerator 1'] = '40280381-4555-E1C1-0145-85C7311720F5';
146 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 1']['IPP'] = '10127790-AE94-4070-9DD3-1D3776D08D7C';
147 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 1']['DENOM'] = '3B3C1568-F875-49B1-9090-E2F494EECBB6';
148 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 1']['DENEX'] = 'B288D5A4-D573-4FAA-92D6-0B01E1B35C7A';
149 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 1']['NUMER'] = 'FD4649BD-B962-4CBE-BF4A-C2F95F3EA08E';
150 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 1']['STRAT'] = '40280381-3D61-56A7-013E-5D53298E6DA3';
151 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 1']['DISPLAY_TEXT'] = 'BMI Recorded, RS1: 3-11';
153 $preDefinedUniqIDRules['0024']['Population Criteria 2']['Numerator 2'] = '40280381-4555-E1C1-0145-85C7311720F5';
154 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 2']['IPP'] = '10127790-AE94-4070-9DD3-1D3776D08D7C';
155 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 2']['DENOM'] = '3B3C1568-F875-49B1-9090-E2F494EECBB6';
156 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 2']['DENEX'] = 'B288D5A4-D573-4FAA-92D6-0B01E1B35C7A';
157 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 2']['NUMER'] = '52FBD726-4DD1-48F5-98B9-7175754923E1';
158 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 2']['STRAT'] = '40280381-3D61-56A7-013E-5D53298E6DA3';
159 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 2']['DISPLAY_TEXT'] = 'BMI Recorded, RS2: 12-17';
161 $preDefinedUniqIDRules['0024']['Population Criteria 2']['Numerator 3'] = '40280381-4555-E1C1-0145-85C7311720F5';
162 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 3']['IPP'] = '10127790-AE94-4070-9DD3-1D3776D08D7C';
163 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 3']['DENOM'] = '3B3C1568-F875-49B1-9090-E2F494EECBB6';
164 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 3']['DENEX'] = 'B288D5A4-D573-4FAA-92D6-0B01E1B35C7A';
165 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 3']['NUMER'] = 'C43CE779-C5EE-4C15-A4CC-AF1C446CFB09';
166 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 3']['STRAT'] = '40280381-3D61-56A7-013E-5D53298E6DA3';
167 $preDefPopIdArr['0024']['Population Criteria 2']['Numerator 3']['DISPLAY_TEXT'] = 'Nutrition Counseling, RS1: 3-11';
169 $preDefinedUniqIDRules['0024']['Population Criteria 3']['Numerator 1'] = '40280381-4555-E1C1-0145-85C7311720F5';
170 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 1']['IPP'] = '10127790-AE94-4070-9DD3-1D3776D08D7C';
171 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 1']['DENOM'] = '3B3C1568-F875-49B1-9090-E2F494EECBB6';
172 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 1']['DENEX'] = 'B288D5A4-D573-4FAA-92D6-0B01E1B35C7A';
173 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 1']['NUMER'] = 'FD4649BD-B962-4CBE-BF4A-C2F95F3EA08E';
174 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 1']['STRAT'] = '40280381-3D61-56A7-013E-5D532AF06DA5';
175 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 1']['DISPLAY_TEXT'] = 'Nutrition Counseling, RS2: 12-17';
177 $preDefinedUniqIDRules['0024']['Population Criteria 3']['Numerator 2'] = '40280381-4555-E1C1-0145-85C7311720F5';
178 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 2']['IPP'] = '10127790-AE94-4070-9DD3-1D3776D08D7C';
179 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 2']['DENOM'] = '3B3C1568-F875-49B1-9090-E2F494EECBB6';
180 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 2']['DENEX'] = 'B288D5A4-D573-4FAA-92D6-0B01E1B35C7A';
181 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 2']['NUMER'] = '52FBD726-4DD1-48F5-98B9-7175754923E1';
182 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 2']['STRAT'] = '40280381-3D61-56A7-013E-5D532AF06DA5';
183 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 2']['DISPLAY_TEXT'] = 'Physical Activity Counseling, RS1: 3-11';
185 $preDefinedUniqIDRules['0024']['Population Criteria 3']['Numerator 3'] = '40280381-4555-E1C1-0145-85C7311720F5';
186 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 3']['IPP'] = '10127790-AE94-4070-9DD3-1D3776D08D7C';
187 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 3']['DENOM'] = '3B3C1568-F875-49B1-9090-E2F494EECBB6';
188 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 3']['DENEX'] = 'B288D5A4-D573-4FAA-92D6-0B01E1B35C7A';
189 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 3']['NUMER'] = 'C43CE779-C5EE-4C15-A4CC-AF1C446CFB09';
190 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 3']['STRAT'] = '40280381-3D61-56A7-013E-5D532AF06DA5';
191 $preDefPopIdArr['0024']['Population Criteria 3']['Numerator 3']['DISPLAY_TEXT'] = 'Physical Activity Counseling, RS2: 12-17';
193 $preDefPopIdArr['0024']['STRAT1'] = '40280381-3D61-56A7-013E-5D53298E6DA3';
194 $preDefPopIdArr['0024']['STRAT2'] = '40280381-3D61-56A7-013E-5D532AF06DA5';
196 //Multiple Numerator NQF# Array declaration
197 $multNumNQFArr = array('0421', '0024');
198 $countNumNQFArr = array();
199 $countNumNQFArr['0421'] = 2;//two Numerators
200 $countNumNQFArr['0024'] = 9;//Nine Numerators
202 //Initiation of all QRDA needed elements
203 $CQMeausesArr = array();
204 $CQMeausesArr['init_patients'] = "Initial Patient Population";
205 $CQMeausesArr['exclude_patients'] = "Denominator Exclusions";
206 $CQMeausesArr['denom_patients'] = "Denominator";
207 $CQMeausesArr['numer_patients'] = "Numerator";
208 $CQMeausesArr['exception_patients'] = "Denominator Exceptions";
210 $cqmItemizedArr = array();
211 $cqmItemizedArr['init_patients'] = "init_patients";
212 $cqmItemizedArr['exclude_patients'] = "exclude";
213 $cqmItemizedArr['denom_patients'] = "all";
214 $cqmItemizedArr['numer_patients'] = "pass";
215 $cqmItemizedArr['exception_patients'] = "exception";
217 //QRDA Needed Ethnicity
218 $mainEthiArr = array(0 => 'Not Hispanic or Latino', 1 => 'Hispanic or Latino');
219 $mainEthiCodeArr = array(0 => '2186-5', 1 => '2135-2');
222 $mainQrdaRaceArr = array(0 => 'American Indian or Alaska Native', 1 => 'Asian', 2 => 'Black or African American', 3 => 'Native Hawaiian or Other Pacific Islander', 4 => 'White', 5 => 'Other');
223 $mainQrdaRaceCodeArr = array(0 => '1002-5', 1 => '2028-9', 2 => '2054-5', 3 => '2076-8', 4 => '2106-3', 5 => '2131-1');
225 $mainQrdaPopulationIncArr = array();
226 $mainQrdaPopulationIncArr['init_patients'] = "IPP";
227 $mainQrdaPopulationIncArr['exclude_patients'] = "DENEX";
228 $mainQrdaPopulationIncArr['denom_patients'] = "DENOM";
229 $mainQrdaPopulationIncArr['numer_patients'] = "NUMER";
230 $mainQrdaPopulationIncArr['exception_patients'] = "DENEXCEP";
231 $mainQrdaPopulationIncArr['measure_population'] = "MSRPOPL";
232 $mainQrdaPopulationIncArr['numer_exclusion'] = "NUMEX";
235 $mainQrdaGenderCodeArr = array();
236 $mainQrdaGenderCodeArr['F'] = "Female";
237 $mainQrdaGenderCodeArr['M'] = "Male";
238 $mainQrdaGenderCodeArr['UN'] = "Unknown";
240 //QRDA Needed Payer Info
241 $mainQrdaPayerCodeArr = array();
242 $mainQrdaPayerCodeArr['A'] = "Medicare";
243 $mainQrdaPayerCodeArr['B'] = "Medicaid";
244 $mainQrdaPayerCodeArr['C'] = "Private Health Insurance";
245 $mainQrdaPayerCodeArr['D'] = "Other";
247 //Payer Codes According to Cypress Codes
248 $mainQrdaPayerCodeSendArr = array();
249 $mainQrdaPayerCodeSendArr['A'] = "1";
250 $mainQrdaPayerCodeSendArr['B'] = "2";
251 $mainQrdaPayerCodeSendArr['C'] = "5";
252 $mainQrdaPayerCodeSendArr['D'] = "349";
255 $form_provider = $_GET['form_provider'];
257 //Get Report Information
258 $report_id = $_GET['report_id'];
259 $report_view = collectReportDatabase($report_id);
260 $target_date = $report_view['date_target'];
261 $dataSheet = json_decode($report_view['data'], true);
263 //Needed array for Rule NQF#0024 Stratification
264 $stratumCheckArr = array();
265 if (count($dataSheet) > 0) {
267 foreach ($dataSheet as $row) {
268 $itemized_test_id = $row['itemized_test_id'];
269 $numerator_label = $row['numerator_label'];
270 if ($row['cqm_nqf_code'] == "0024") {
271 if ($row['population_label'] == "Population Criteria 2") {
272 if ($row['numerator_label'] == "Numerator 1") {
273 $stratum_1_ipp = $row['initial_population'];
274 $stratum_1_exclude = $row['excluded'];
275 $stratum_1_denom = $row['pass_filter'];
276 $stratum_1_numer1 = $row['pass_target'];
277 } elseif ($row['numerator_label'] == "Numerator 2") {
278 $stratum_1_numer2 = $row['pass_target'];
279 } elseif ($row['numerator_label'] == "Numerator 3") {
280 $stratum_1_numer3 = $row['pass_target'];
282 } elseif ($row['population_label'] == "Population Criteria 3") {
283 if ($row['numerator_label'] == "Numerator 1") {
284 $stratum_2_ipp = $row['initial_population'];
285 $stratum_2_exclude = $row['excluded'];
286 $stratum_2_denom = $row['pass_filter'];
287 $stratum_2_numer1 = $row['pass_target'];
288 } elseif ($row['numerator_label'] == "Numerator 2") {
289 $stratum_2_numer2 = $row['pass_target'];
290 } elseif ($row['numerator_label'] == "Numerator 3") {
291 $stratum_2_numer3 = $row['pass_target'];
297 $stratum[1] = array('init_patients' => $stratum_1_ipp,
298 'exclude_patients' => $stratum_1_exclude,
299 'denom_patients' => $stratum_1_denom,
300 'numer_patients' => $stratum_1_numer1,
301 'numer2' => $stratum_1_numer2,
302 'numer3' => $stratum_1_numer3);
304 $stratum[2] = array('init_patients' => $stratum_2_ipp,
305 'exclude_patients' => $stratum_2_exclude,
306 'denom_patients' => $stratum_2_denom,
307 'numer_patients' => $stratum_2_numer1,
308 'numer2' => $stratum_2_numer2,
309 'numer3' => $stratum_2_numer3);
313 $from_date = date('Y', strtotime($target_date)) . "-01-01";
314 $to_date = date('Y', strtotime($target_date)) . "-12-31";
315 $xml = new QRDAXml();
317 #################################################################################################
318 ####################### HEADER ELEMENTS START #####################################################
319 #################################################################################################
320 //Open Main Clinical Document
321 $xml->open_clinicaldocument();
323 $xml->self_realmcode();
327 $tempId = '2.16.840.1.113883.10.20.27.1.1';
328 $xml->self_templateid($tempId);
330 $xml->unique_id
= getUuid();
334 //Main Title Display to XML
335 $main_title = "QRDA Calculated Summary Report";
336 $xml->add_title($main_title);
338 //Effective date and time
339 $eff_datetime = date('Ymdhis', strtotime($target_date));
340 $xml->self_efftime($eff_datetime);
342 $xml->self_confidentcode();
347 $setidVal = getUuid();
348 $xml->self_setid($setidVal);
351 $xml->self_version();
353 //Record Target Elements
354 $xml->open_recordTarget();
355 $xml->add_patientRole();
356 $xml->close_recordTarget();
358 ############### Author Info #######################
361 $auth_dtime = date('Ymdhis', strtotime(date('Y-m-d H:i:s')));
362 $xml->self_authorTime($auth_dtime);
364 $xml->open_assignAuthor();
365 $authorsetid = getUuid();
366 $xml->self_customId($authorsetid);
367 if ($form_provider != "") {
368 $userRow = sqlQuery("SELECT facility, facility_id, federaltaxid, npi, phone,fname, lname FROM users WHERE id=?", array($form_provider));
369 $facility_name = $userRow['facility'];
370 $facility_id = $userRow['facility_id'];
373 //$xml->self_customTag('telecom', array('value' => $userRow['phone'], 'use'=>'WP'));
375 //assignedAuthoringDevice Start
376 $xml->open_customTag('assignedAuthoringDevice');
378 $xml->element('softwareName', 'CYPRESS');
380 //assignedAuthoringDevice Close
381 $xml->close_customTag();
384 $facilResRow = $facilityService->getById($facility_id);
385 $xml->add_authReprestOrginisation($facilResRow);
386 //$xml->add_facilAddress($facilResRow);
387 $xml->close_assignAuthor();
388 $xml->close_author();
390 ############### Custodian Info #######################
391 $xml->open_custodian();
392 $xml->open_assgnCustodian();
393 $xml->add_represtCustodianOrginisation($facilResRow);
394 $xml->close_assgnCustodian();
395 $xml->close_custodian();
398 ############### Information Recipient #######################
399 $xml->open_infoRecipient();
400 $xml->add_indententRecipient();
401 $xml->close_infoRecipient();
404 ############### Legal Authenticator #######################
405 $xml->open_legalAuthenticator();
406 $auth_dtime = date('Ymdhis', strtotime(date('Y-m-d H:i:s')));
407 $xml->self_authorTime($auth_dtime);
408 $xml->self_legalSignCode();
410 $xml->open_assignedEntity();
411 $assignedEntityId = getUuid();
412 $xml->self_customId($assignedEntityId);
414 $xml->open_customTag('assignedPerson');
417 $userNameArr = array('fname' => $userRow['fname'], 'lname' => $userRow['lname']);
418 $xml->add_providerName($userNameArr);
420 //assignedPerson Close
421 $xml->close_customTag();
423 //Represent Origination Name
424 $xml->add_authReprestOrginisation($facilResRow);
425 $xml->close_assignedEntity();
427 $xml->close_legalAuthenticator();
430 ############### Participant is Device(optional) #######################
431 $participentDevArr = array();
432 $xml->open_participant_data('DEV');//DEV -- Device
433 $xml->open_assocEntityData('RGPR');//RGPR -- Regulated Product
434 $participentDevArr['root'] = '2.16.840.1.113883.3.2074.1';
435 $participentDevArr['extension'] = '1a2b3c';
436 $xml->self_particpantIdInfo($participentDevArr);
437 $xml->self_participantCodeDevice();
438 $xml->close_assocEntityData();
439 $xml->close_participant_data();
441 ############### Participant is Location(optional) #######################
442 $participentLocArr = array();
443 $xml->open_participant_data('LOC');//LOC -- Location
444 $xml->open_assocEntityData('SDLOC');//SDLOC -- Service Delivery Location
445 $participentLocArr['root'] = '2.16.840.1.113883.3.249.5.1';
446 $participentLocArr['extension'] = 'OK666333';
447 $xml->self_particpantIdInfo($participentLocArr);
448 $xml->self_participantCodeLocation();
450 $xml->add_facilAddress($facilResRow);
451 $xml->close_assocEntityData();
452 $xml->close_participant_data();
455 ############### documentationOf START #######################
456 $xml->open_customTag('documentationOf');
458 $xml->open_customTag('serviceEvent', array('classCode' => 'PCPR'));
460 $timeArr = array('low' => date('Ymd', strtotime($from_date)), 'high' => date('Ymd', strtotime($to_date)));
461 $xml->add_entryEffectTime($timeArr);
463 $xml->open_customTag('performer', array('typeCode' => 'PRF'));
465 $xml->open_customTag('assignedEntity');
467 $npi_provider = !empty($userRow['npi']) ?
$userRow['npi'] : '123456789';
468 $xml->self_customTag('id', array('root' => '2.16.840.1.113883.4.6', 'extension' => $npi_provider));
470 if ($userRow['phone'] != "") {
471 $xml->self_customTag('telecom', array('value' => $userRow['phone'], 'use' => 'WP'));
474 $xml->open_customTag('assignedPerson');
477 $userNameArr = array('fname' => $userRow['fname'], 'lname' => $userRow['lname']);
478 $xml->add_providerName($userNameArr);
480 //assignedPerson Close
481 $xml->close_customTag();
483 $xml->open_customTag('representedOrganization');
485 $tin_provider = $userRow['federaltaxid'];
486 if ($tin_provider != "") {
487 $xml->self_customTag('id', array('root' => '2.16.840.1.113883.4.2', 'extension' => $tin_provider));
490 $xml->add_facilName($facility_name);
492 $xml->add_facilAddress($facilResRow);
494 //representedOrganization Close
495 $xml->close_customTag();
497 //assignedEntity Close
498 $xml->close_customTag();
501 $xml->close_customTag();
504 $xml->close_customTag();
506 //documentationOf Close
507 $xml->close_customTag();
508 ############### documentationOf END #######################
511 ############### authorization (optional) #########################
513 #################################################################################################
514 ####################### HEADER ELEMENTS END #####################################################
515 #################################################################################################
519 #################################################################################################
520 ######################### Main Component Open ###################################################
521 $xml->open_mainComponent();
523 ############### Structure Body Open #######################
524 $xml->open_structuredBody();
526 ##################### LOOP Component(s) START ########################
528 ###################### Report Parameters Open #####################
529 //QRDA Category III Reporting Parameters Section (CMS EP) [section: templateId 2.16.840.1.113883.10.20.27.2.6
530 $xml->open_loopComponent();
532 $xml->open_section();
534 $tempID = '2.16.840.1.113883.10.20.17.2.1';
535 $xml->self_templateid($tempID);
537 $tempID = '2.16.840.1.113883.10.20.27.2.2';
538 $xml->self_templateid($tempID);
540 $tempID = '2.16.840.1.113883.10.20.27.2.6';
541 $xml->self_templateid($tempID);
542 $arr = array('code' => '55187-9', 'codeSystem' => '2.16.840.1.113883.6.1');
543 $xml->self_codeCustom($arr);
544 $title = "Reporting Parameters";
545 $xml->add_title($title);
549 $item_title = "Reporting period: " . date('d M Y', strtotime($from_date)) . " - " . date('d M Y', strtotime($to_date));
550 $xml->add_item($item_title);
555 $xml->open_entry($typeCode);
556 $arr = array('classCode' => 'ACT', 'moodCode' => 'EVN');
557 $xml->open_act($arr);
559 $tempID = '2.16.840.1.113883.10.20.17.3.8';
560 $xml->self_templateid($tempID);
562 $tempID = '2.16.840.1.113883.10.20.27.3.23';
563 $xml->self_templateid($tempID);
566 $xml->self_customId($actId);
568 $arr = array('code' => '252116004', 'codeSystem' => '2.16.840.1.113883.6.96', 'displayName' => 'Observation Parameters');
569 $xml->self_codeCustom($arr);
571 $timeArr = array('low' => date('Ymd', strtotime($from_date)), 'high' => date('Ymd', strtotime($to_date)));
572 $xml->add_entryEffectTime($timeArr);
577 $xml->close_section();
579 $xml->close_loopComponent();
580 ###################### Report Parameters Close #####################
582 ###################### Measure Section Open #####################
583 $xml->open_loopComponent();
585 $xml->open_section();
587 $tempID = '2.16.840.1.113883.10.20.27.2.1';
588 $xml->self_templateid($tempID);
590 $tempID = '2.16.840.1.113883.10.20.24.2.2';
591 $xml->self_templateid($tempID);
593 $tempID = '2.16.840.1.113883.10.20.27.2.3';
594 $xml->self_templateid($tempID);
596 $arr = array('code' => '55186-1', 'codeSystem' => '2.16.840.1.113883.6.1');
597 $xml->self_codeCustom($arr);
598 $title = "Measure Section";
599 $xml->add_title($title);
604 $tabArr = array('border' => 1, 'width' => '100%');
605 if (count($dataSheet) > 0) {
606 $uniqIdArr = array();
609 foreach ($dataSheet as $row) {
610 $itemized_test_id = $row['itemized_test_id'];
611 $numerator_label = $row['numerator_label'];
613 //CQM Rules 2014 set, 0013 is 0018
614 if ($row['cqm_nqf_code'] == "0013") {
615 $row['cqm_nqf_code'] = "0018";
619 $xml->open_customTag('table', $tabArr);
621 $xml->open_customTag('thead');
623 $xml->open_customTag('tr');
625 $xml->add_trElementsTitles();
628 $xml->close_customTag();
631 $xml->close_customTag();
633 $xml->open_customTag('tbody');
634 $xml->open_customTag('tr');
636 $tdTitle = generate_display_field(array('data_type' => '1','list_id' => 'clinical_rules'), $row['id']);
638 if (!empty($row['cqm_pqri_code'])) {
639 $tdTitle .= " " . xlt('PQRI') . ":" . text($row['cqm_pqri_code']) . " ";
642 if (!empty($row['cqm_nqf_code'])) {
643 $tdTitle .= " " . xlt('NQF') . ":" . text($row['cqm_nqf_code']) . " ";
646 if (!(empty($row['concatenated_label']))) {
647 $tdTitle .= ", " . xlt($row['concatenated_label']) . " ";
650 $tdVersionNeutral = getUuid();
652 if ($preDefinedUniqIDRules[$row['cqm_nqf_code']] != "") {
653 if (($row['cqm_nqf_code'] == "0421" )) {
654 $tdVersionSpecific = $preDefinedUniqIDRules[$row['cqm_nqf_code']][$row['numerator_label']];
655 } elseif ($row['cqm_nqf_code'] == "0024") {
656 $tdVersionSpecific = $preDefinedUniqIDRules[$row['cqm_nqf_code']][$row['population_label']][$row['numerator_label']];
658 $tdVersionSpecific = $preDefinedUniqIDRules[$row['cqm_nqf_code']];
661 $uniqIdArr[] = $tdVersionSpecific;
663 $tdVersionSpecific = getUuid();
664 $uniqIdArr[] = $tdVersionSpecific;
667 $dataArr = array(0 => $tdTitle, 1 => $tdVersionNeutral, 2 => $tdVersionSpecific);
668 $xml->add_trElementsValues($dataArr);
671 $xml->close_customTag();
673 $xml->close_customTag();
675 $xml->close_customTag();
677 //Open List Item Wise
681 $xml->open_customTag('item');
682 $arrContent = array('name' => 'Performance Rate', 'value' => $row['percentage']);
683 $xml->innerContent($arrContent);
684 $xml->close_customTag();
687 //All CQM Measures taken here
688 foreach ($CQMeausesArr as $cqmKey => $cqmVal) {
689 //DENEXCEP(Denominator Exception not needed for some rules are skipping here)
690 if ((in_array($row['cqm_nqf_code'], $denExcepNotNeedRules) ) && ($cqmKey == "exception_patients")) {
695 if ($cqmKey == "init_patients") {
696 $itemPatArr = collectItemizedPatientsCdrReport($report_id, $itemized_test_id, $cqmItemizedArr[$cqmKey]);
698 $itemPatArr = collectItemizedPatientsCdrReport($report_id, $itemized_test_id, $cqmItemizedArr[$cqmKey], $numerator_label);
701 $fullPatArr = array();
702 foreach ($itemPatArr as $itemPatInfo) {
703 $fullPatArr[] = $itemPatInfo['pid'];
706 //Initial Patient Population
707 $xml->open_customTag('item');
708 $arrContent = array('name' => $cqmVal, 'value' => count($fullPatArr));
709 $xml->innerContent($arrContent);
711 $detailsArr = getQRDAPatientNeedInfo($fullPatArr);
716 //Gender Section Display
717 foreach ($mainQrdaGenderCodeArr as $GKey => $GVal) {
718 $xml->open_customTag('item');
719 $genderInfo = $detailsArr['gender'][$GVal];
720 $arrContent = array('name' => $GVal, 'value' => $genderInfo);
721 $xml->innerContent($arrContent);
722 $xml->close_customTag();
725 //Ethnicity Section Display
726 foreach ($mainEthiArr as $ethKey => $ethVal) {
727 $ethnicity_data = $detailsArr['ethnicity'][$ethVal];
728 $xml->open_customTag('item');
729 $arrContent = array('name' => 'Ethnicity - ' . $ethVal, 'value' => $ethnicity_data);
730 $xml->innerContent($arrContent);
731 $xml->close_customTag();
734 //Race Section Display
735 foreach ($mainQrdaRaceArr as $RKey => $RVal) {
736 $race_data = $detailsArr['race'][$RVal];
737 $xml->open_customTag('item');
738 $arrContent = array('name' => 'Race - ' . $RVal, 'value' => $race_data);
739 $xml->innerContent($arrContent);
740 $xml->close_customTag();
743 //Payer Type Section Display
744 $payerCheckArr = getQRDAPayerInfo($fullPatArr);
745 foreach ($mainQrdaPayerCodeArr as $PKey => $PVal) {
746 $xml->open_customTag('item');
747 $arrContent = array('name' => 'Payer - ' . $PVal, 'value' => $payerCheckArr[$PVal]);
748 $xml->innerContent($arrContent);
749 $xml->close_customTag();
754 $xml->close_customTag();
763 #######################################################################
764 ######################### QUALITY MEASURES START ######################
765 #######################################################################
766 if (count($dataSheet) > 0) {
768 $skipMultNumArr = array();
769 $dataChkArr = array();
770 foreach ($multNumNQFArr as $multNumVal) {
771 $skipMultNumArr[$multNumVal] = false;
772 $dataChkArr[$multNumVal] = 0;
776 foreach ($dataSheet as $row) {
777 $itemized_test_id = $row['itemized_test_id'];
778 $numerator_label = $row['numerator_label'];
780 //if($row['cqm_nqf_code'] == "0028a") continue;
782 //if($row['cqm_nqf_code'] == "0038"){
783 // if(in_array($row['numerator_label'], $NQF38NumArr)) continue;
786 if (in_array($row['cqm_nqf_code'], $multNumNQFArr)) {
787 $dataChkArr[$row['cqm_nqf_code']]++
;
790 //CQM Rules 2014 set, 0013 is 0018
791 if ($row['cqm_nqf_code'] == "0013") {
792 $row['cqm_nqf_code'] = "0018";
795 $tdTitle = generate_display_field(array('data_type' => '1','list_id' => 'clinical_rules'), $row['id']);
796 if (!empty($row['cqm_pqri_code'])) {
797 $tdTitle .= " " . xlt('PQRI') . ":" . text($row['cqm_pqri_code']) . " ";
800 if (!empty($row['cqm_nqf_code'])) {
801 $tdTitle .= " " . xlt('NQF') . ":" . text($row['cqm_nqf_code']) . " ";
804 if (!(empty($row['concatenated_label']))) {
805 $tdTitle .= ", " . xlt($row['concatenated_label']) . " ";
808 ###########################################################
809 if (( !isset($skipMultNumArr[$row['cqm_nqf_code']]) ) ||
($skipMultNumArr[$row['cqm_nqf_code']] == false)) {
814 $arr = array('classCode' => 'CLUSTER', 'moodCode' => 'EVN');
815 $xml->open_customTag('organizer', $arr);
817 $tempID = "2.16.840.1.113883.10.20.24.3.98";
818 $xml->self_templateid($tempID);
820 $tempID = "2.16.840.1.113883.10.20.27.3.1";
821 $xml->self_templateid($tempID);
823 //$tempID = "2.16.840.1.113883.10.20.27.3.17";
824 //$xml->self_templateid($tempID);
826 $xml->self_customId($actId);
828 $arr = array('code' => 'completed');
829 $xml->self_customTag('statusCode', $arr);
832 $arr = array('typeCode' => 'REFR');
833 $xml->open_customTag('reference', $arr);
835 //externalDocument Start
836 $arr = array('classCode' => 'DOC', 'moodCode' => 'EVN');
837 $xml->open_customTag('externalDocument', $arr);
839 //$exDocID = getUuid();
840 $exDocID = $uniqIdArr[$innrCnt];
841 //$xml->self_customId($exDocID);
842 $xml->self_customTag('id', array('root' => '2.16.840.1.113883.4.738', 'extension' => $exDocID));
844 $arr = array('code' => '57024-2', 'displayName' => 'Health Quality Measure Document', 'codeSystem' => '2.16.840.1.113883.6.1', 'codeSystemName' => 'LOINC');
845 $xml->self_codeCustom($arr);
847 $dispContntTitle = str_replace("&", '', $tdTitle);
848 $xml->textDispContent($dispContntTitle);
850 //externalDocument Close
851 $xml->close_customTag();
854 $xml->close_customTag();
857 ############### Performance Rate for Proportion Measure template START###################
858 $xml->open_loopComponent();
861 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
863 $tempID = "2.16.840.1.113883.10.20.27.3.14";
864 $xml->self_templateid($tempID);
866 $tempID = "2.16.840.1.113883.10.20.27.3.25";
867 $xml->self_templateid($tempID);
869 $arr = array('code' => '72510-1', 'displayName' => 'Performance Rate', 'codeSystem' => '2.16.840.1.113883.6.1', 'codeSystemName' => 'SNOMED-CT');
870 $xml->self_codeCustom($arr);
872 $arr = array('code' => 'completed');
873 $xml->self_customTag('statusCode', $arr);
875 $percentage = str_replace("%", '', $row['percentage']);
876 $arr = array('xsi:type' => 'REAL', 'value' => $percentage / 100);
877 $xml->self_customTag('value', $arr);
880 $arr = array('typeCode' => 'REFR');
881 $xml->open_customTag('reference', $arr);
883 //externalObservation Start
884 $arr = array('classCode' => 'OBS', 'moodCode' => 'EVN');
885 $xml->open_customTag('externalObservation', $arr);
888 //$exDocID = getUuid();
891 if (($row['cqm_nqf_code'] == "0421" )) {
892 $exDocID = $preDefPopIdArr[$row['cqm_nqf_code']][$row['numerator_label']]["NUMER"];
893 } elseif (($row['cqm_nqf_code'] == "0024")) {
894 $exDocID = $preDefPopIdArr[$row['cqm_nqf_code']][$row['population_label']][$row['numerator_label']]["NUMER"];
896 if ($preDefPopIdArr[$row['cqm_nqf_code']]["NUMER"] != "") {
897 $exDocID = $preDefPopIdArr[$row['cqm_nqf_code']]["NUMER"];
899 $exDocID = getUuid();
903 $xml->self_customId($exDocID);
905 $arr = array('code' => 'NUMER', 'displayName' => 'Numerator', 'codeSystem' => '2.16.840.1.113883.5.1063', 'codeSystemName' => 'ObservationValue');
906 $xml->self_codeCustom($arr);
908 //externalObservation Close
909 $xml->close_customTag();
912 $xml->close_customTag();
915 $xml->close_customTag();
917 $xml->close_loopComponent();
918 ############### Performance Rate for Proportion Measure template END ###################
921 //All CQM Measures taken here
922 foreach ($CQMeausesArr as $cqmKey => $cqmVal) {
923 //DENEXCEP(Denominator Exception not needed for some rules are skipping here)
924 if ((in_array($row['cqm_nqf_code'], $denExcepNotNeedRules) ) && ($cqmKey == "exception_patients")) {
928 //cqm 0024 alllowing only nuemerator 2 and numerator 3 for ipp1,ipp2 and 1pp3 to avoid repeatation
929 if ($row['cqm_nqf_code'] == '0024' && ($row['numerator_label'] == "Numerator 2" ||
$row['numerator_label'] == "Numerator 3") && $cqmKey != 'numer_patients') {
933 if ($row['cqm_nqf_code'] == '0024' && ($row['population_label'] == "Population Criteria 2" ||
$row['population_label'] == "Population Criteria 3")) {
939 if ($cqmKey == "init_patients") {
940 $itemPatArr = collectItemizedPatientsCdrReport($report_id, $itemized_test_id, $cqmItemizedArr[$cqmKey]);
942 $itemPatArr = collectItemizedPatientsCdrReport($report_id, $itemized_test_id, $cqmItemizedArr[$cqmKey], $numerator_label);
945 $fullPatArr = array();
946 foreach ($itemPatArr as $itemPatInfo) {
947 $fullPatArr[] = $itemPatInfo['pid'];
950 $detailsArr = getQRDAPatientNeedInfo($fullPatArr);
951 ############### Initial patient population template START###################
952 $xml->open_loopComponent();
955 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
957 $tempID = "2.16.840.1.113883.10.20.27.3.5";
958 $xml->self_templateid($tempID);
960 $tempID = "2.16.840.1.113883.10.20.27.3.16";
961 $xml->self_templateid($tempID);
963 $arr = array('code' => 'ASSERTION', 'displayName' => 'Assertion', 'codeSystem' => '2.16.840.1.113883.5.4', 'codeSystemName' => 'ActCode');
964 $xml->self_codeCustom($arr);
966 $arr = array('code' => 'completed');
967 $xml->self_customTag('statusCode', $arr);
969 $arr = array('xsi:type' => 'CD', 'code' => $mainQrdaPopulationIncArr[$cqmKey], 'displayName' => $cqmVal, 'codeSystem' => '2.16.840.1.113883.5.1063', 'codeSystemName' => 'ObservationValue');
970 $xml->self_customTag('value', $arr);
972 //entryRelationship Open
973 $xml->open_customTag('entryRelationship', array('typeCode' => 'SUBJ', 'inversionInd' => 'true'));
976 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
978 $tempID = "2.16.840.1.113883.10.20.27.3.3";
979 $xml->self_templateid($tempID);
981 $tempID = "2.16.840.1.113883.10.20.27.3.24";
982 $xml->self_templateid($tempID);
984 $arr = array('code' => 'MSRAGG', 'displayName' => 'rate aggregation', 'codeSystem' => '2.16.840.1.113883.5.4', 'codeSystemName' => 'ActCode');
985 $xml->self_codeCustom($arr);
987 //$arr = array('code'=>'completed');
988 //$xml->self_customTag('statusCode', $arr);
990 $arr = array('xsi:type' => 'INT', 'value' => count($fullPatArr));
991 $xml->self_customTag('value', $arr);
993 $arr = array('code' => 'COUNT', 'displayName' => 'Count', 'codeSystem' => '2.16.840.1.113883.5.84', 'codeSystemName' => 'ObservationMethod');
994 $xml->self_customTag('methodCode', $arr);
997 $xml->close_customTag();
999 //entryRelationship Close
1000 $xml->close_customTag();
1002 #### Stratum Start (Stratification)#####
1003 if ($row['cqm_nqf_code'] == '0024') {
1005 for (; $strat_count <= 2; $strat_count++
) {
1006 $strata_value = $stratum[$strat_count][$cqmKey];
1008 if ($row['numerator_label'] == "Numerator 2") {
1009 $strata_value = $stratum[$strat_count]['numer2'];
1010 } elseif ($row['numerator_label'] == "Numerator 3") {
1011 $strata_value = $stratum[$strat_count]['numer3'];
1014 //entryRelationship Open
1015 $xml->open_customTag('entryRelationship', array('typeCode' => 'COMP'));
1018 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
1020 $tempID = "2.16.840.1.113883.10.20.27.3.4";
1021 $xml->self_templateid($tempID);
1023 $tempID = "2.16.840.1.113883.10.20.27.3.20";
1024 $xml->self_templateid($tempID);
1026 $arr = array('code' => 'ASSERTION', 'displayName' => 'Assertion', 'codeSystem' => '2.16.840.1.113883.5.4', 'codeSystemName' => 'ActCode');
1027 $xml->self_codeCustom($arr);
1029 $arr = array('code' => 'completed');
1030 $xml->self_customTag('statusCode', $arr);
1033 $xml->open_customTag('value', array('xsi:type' => 'CD', 'nullFlavor' => 'OTH'));
1035 $stratumText = $preDefPopIdArr[$row['cqm_nqf_code']][$row['population_label']][$row['numerator_label']]['DISPLAY_TEXT'];
1036 $xml->element('originalText', "Stratum " . $strat_count);
1039 $xml->close_customTag();
1041 //entryRelationship Open
1042 $xml->open_customTag('entryRelationship', array('typeCode' => 'SUBJ', 'inversionInd' => 'true'));
1045 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
1047 $tempID = "2.16.840.1.113883.10.20.27.3.3";
1048 $xml->self_templateid($tempID);
1050 $arr = array('code' => 'MSRAGG', 'displayName' => 'rate aggregation', 'codeSystem' => '2.16.840.1.113883.5.4', 'codeSystemName' => 'ActCode');
1051 $xml->self_codeCustom($arr);
1053 $arr = array('xsi:type' => 'INT', 'value' => $strata_value);
1054 $xml->self_customTag('value', $arr);
1056 $arr = array('code' => 'COUNT', 'displayName' => 'Count', 'codeSystem' => '2.16.840.1.113883.5.84', 'codeSystemName' => 'ObservationMethod');
1057 $xml->self_customTag('methodCode', $arr);
1060 $xml->close_customTag();
1062 //entryRelationship Close
1063 $xml->close_customTag();
1066 $arr = array('typeCode' => 'REFR');
1067 $xml->open_customTag('reference', $arr);
1069 //externalObservation Start
1070 $arr = array('classCode' => 'OBS', 'moodCode' => 'EVN');
1071 $xml->open_customTag('externalObservation', $arr);
1073 //Modified HQMF_ID for CQM IDS
1074 //$refID = $preDefPopIdArr[$row['cqm_nqf_code']][$row['population_label']][$row['numerator_label']]['STRAT'];
1075 $refID = $preDefPopIdArr[$row['cqm_nqf_code']]['STRAT' . $strat_count];
1077 $xml->self_customId($refID);
1079 //externalObservation Close
1080 $xml->close_customTag();
1083 $xml->close_customTag();
1086 $xml->close_customTag();
1088 //entryRelationship Close
1089 $xml->close_customTag();
1093 #### Stratum END #####
1095 ####################################################
1096 ####################################################
1097 //Sex Supplemental Data Element START
1098 ####################################################
1099 ####################################################
1101 foreach ($mainQrdaGenderCodeArr as $GKey => $GVal) {
1102 //entryRelationship Open
1103 $xml->open_customTag('entryRelationship', array('typeCode' => 'COMP'));
1106 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
1108 $tempID = "2.16.840.1.113883.10.20.27.3.6";
1109 $xml->self_templateid($tempID);
1111 $tempID = "2.16.840.1.113883.10.20.27.3.21";
1112 $xml->self_templateid($tempID);
1114 $arr = array('code' => '184100006', 'displayName' => 'patient sex', 'codeSystem' => '2.16.840.1.113883.6.96', 'codeSystemName' => 'SNOMED-CT');
1115 $xml->self_codeCustom($arr);
1117 $arr = array('code' => 'completed');
1118 $xml->self_customTag('statusCode', $arr);
1120 $arr = array('xsi:type' => 'CD', 'code' => $GKey, 'codeSystem' => '2.16.840.1.113883.5.1', 'codeSystemName' => 'AdministrativeGenderCode');
1121 $xml->self_customTag('value', $arr);
1123 //entryRelationship Open
1124 $xml->open_customTag('entryRelationship', array('typeCode' => 'SUBJ', 'inversionInd' => 'true'));
1127 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
1129 $tempID = "2.16.840.1.113883.10.20.27.3.3";
1130 $xml->self_templateid($tempID);
1132 $tempID = "2.16.840.1.113883.10.20.27.3.24";
1133 $xml->self_templateid($tempID);
1135 $arr = array('code' => 'MSRAGG', 'displayName' => 'rate aggregation', 'codeSystem' => '2.16.840.1.113883.5.4', 'codeSystemName' => 'ActCode');
1136 $xml->self_codeCustom($arr);
1138 //$arr = array('code'=>'completed');
1139 //$xml->self_customTag('statusCode', $arr);
1141 $arr = array('xsi:type' => 'INT', 'value' => $detailsArr['gender'][$GVal]);
1142 $xml->self_customTag('value', $arr);
1144 $arr = array('code' => 'COUNT', 'displayName' => 'Count', 'codeSystem' => '2.16.840.1.113883.5.84', 'codeSystemName' => 'ObservationMethod');
1145 $xml->self_customTag('methodCode', $arr);
1148 $xml->close_customTag();
1150 //entryRelationship Close
1151 $xml->close_customTag();
1155 $xml->close_customTag();
1157 //entryRelationship Close
1158 $xml->close_customTag();
1161 ####################################################
1162 ####################################################
1163 //Sex Supplemental Data Element END
1164 ####################################################
1165 ####################################################
1167 ####################################################
1168 ####################################################
1169 //Ethnicity Supplemental Data Element (CMS EP) START
1170 ####################################################
1171 ####################################################
1173 foreach ($mainEthiArr as $ethKey => $ethVal) {
1174 //entryRelationship Open
1175 $xml->open_customTag('entryRelationship', array('typeCode' => 'COMP'));
1178 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
1180 $tempID = "2.16.840.1.113883.10.20.27.3.7";
1181 $xml->self_templateid($tempID);
1183 $tempID = "2.16.840.1.113883.10.20.27.3.22";
1184 $xml->self_templateid($tempID);
1186 $arr = array('code' => '364699009', 'displayName' => 'Ethnic Group', 'codeSystem' => '2.16.840.1.113883.6.96', 'codeSystemName' => 'SNOMED-CT');
1187 $xml->self_codeCustom($arr);
1189 $arr = array('code' => 'completed');
1190 $xml->self_customTag('statusCode', $arr);
1192 $arr = array('xsi:type' => 'CD', 'code' => $mainEthiCodeArr[$ethKey], 'displayName' => $ethVal, 'codeSystem' => '2.16.840.1.113883.6.238', 'codeSystemName' => 'Race & Ethnicity - CDC');
1193 $xml->self_customTag('value', $arr);
1195 //entryRelationship Open
1196 $xml->open_customTag('entryRelationship', array('typeCode' => 'SUBJ', 'inversionInd' => 'true'));
1199 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
1201 $tempID = "2.16.840.1.113883.10.20.27.3.3";
1202 $xml->self_templateid($tempID);
1204 $tempID = "2.16.840.1.113883.10.20.27.3.24";
1205 $xml->self_templateid($tempID);
1207 $arr = array('code' => 'MSRAGG', 'displayName' => 'rate aggregation', 'codeSystem' => '2.16.840.1.113883.5.4', 'codeSystemName' => 'ActCode');
1208 $xml->self_codeCustom($arr);
1210 //$arr = array('code'=>'completed');
1211 //$xml->self_customTag('statusCode', $arr);
1213 $arr = array('xsi:type' => 'INT', 'value' => $detailsArr['ethnicity'][$ethVal]);
1214 $xml->self_customTag('value', $arr);
1216 $arr = array('code' => 'COUNT', 'displayName' => 'Count', 'codeSystem' => '2.16.840.1.113883.5.84', 'codeSystemName' => 'ObservationMethod');
1217 $xml->self_customTag('methodCode', $arr);
1220 $xml->close_customTag();
1222 //entryRelationship Close
1223 $xml->close_customTag();
1227 $xml->close_customTag();
1229 //entryRelationship Close
1230 $xml->close_customTag();
1233 ####################################################
1234 ####################################################
1235 //Ethnicity Supplemental Data Element (CMS EP) END
1236 ####################################################
1237 ####################################################
1240 ####################################################
1241 ####################################################
1242 //Race Supplemental Data Element (CMS EP) START
1243 ####################################################
1244 ####################################################
1246 foreach ($mainQrdaRaceArr as $RKey => $RVal) {
1247 //entryRelationship Open
1248 $xml->open_customTag('entryRelationship', array('typeCode' => 'COMP'));
1251 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
1253 $tempID = "2.16.840.1.113883.10.20.27.3.8";
1254 $xml->self_templateid($tempID);
1256 $tempID = "2.16.840.1.113883.10.20.27.3.19";
1257 $xml->self_templateid($tempID);
1259 $arr = array('code' => '103579009', 'displayName' => 'Race', 'codeSystem' => '2.16.840.1.113883.6.96', 'codeSystemName' => 'SNOMED-CT');
1260 $xml->self_codeCustom($arr);
1262 $arr = array('code' => 'completed');
1263 $xml->self_customTag('statusCode', $arr);
1265 $arr = array('xsi:type' => 'CD', 'code' => $mainQrdaRaceCodeArr[$RKey], 'displayName' => $RVal, 'codeSystem' => '2.16.840.1.113883.6.238', 'codeSystemName' => 'Race & Ethnicity - CDC');
1266 $xml->self_customTag('value', $arr);
1268 //entryRelationship Open
1269 $xml->open_customTag('entryRelationship', array('typeCode' => 'SUBJ', 'inversionInd' => 'true'));
1272 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
1274 $tempID = "2.16.840.1.113883.10.20.27.3.3";
1275 $xml->self_templateid($tempID);
1277 $tempID = "2.16.840.1.113883.10.20.27.3.24";
1278 $xml->self_templateid($tempID);
1280 $arr = array('code' => 'MSRAGG', 'displayName' => 'rate aggregation', 'codeSystem' => '2.16.840.1.113883.5.4', 'codeSystemName' => 'ActCode');
1281 $xml->self_codeCustom($arr);
1283 //$arr = array('code'=>'completed');
1284 //$xml->self_customTag('statusCode', $arr);
1286 $arr = array('xsi:type' => 'INT', 'value' => $detailsArr['race'][$RVal]);
1287 $xml->self_customTag('value', $arr);
1289 $arr = array('code' => 'COUNT', 'displayName' => 'Count', 'codeSystem' => '2.16.840.1.113883.5.84', 'codeSystemName' => 'ObservationMethod');
1290 $xml->self_customTag('methodCode', $arr);
1293 $xml->close_customTag();
1295 //entryRelationship Close
1296 $xml->close_customTag();
1300 $xml->close_customTag();
1302 //entryRelationship Close
1303 $xml->close_customTag();
1306 ####################################################
1307 ####################################################
1308 //Race Supplemental Data Element (CMS EP) END
1309 ####################################################
1310 ####################################################
1313 ####################################################
1314 ####################################################
1315 //Payer Supplemental Data Element (CMS EP) START
1316 ####################################################
1317 ####################################################
1318 $payerCheckArr = getQRDAPayerInfo($fullPatArr);
1319 foreach ($mainQrdaPayerCodeArr as $PKey => $PVal) {
1320 //entryRelationship Open
1321 $xml->open_customTag('entryRelationship', array('typeCode' => 'COMP'));
1324 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
1326 $tempID = "2.16.840.1.113883.10.20.27.3.9";
1327 $xml->self_templateid($tempID);
1329 $tempID = "2.16.840.1.113883.10.20.24.3.55";
1330 $xml->self_templateid($tempID);
1332 $tempID = "2.16.840.1.113883.10.20.27.3.18";
1333 $xml->self_templateid($tempID);
1335 $xml->self_setpatientRoleid();
1337 $arr = array('code' => '48768-6', 'displayName' => 'Payment source', 'codeSystem' => '2.16.840.1.113883.6.1', 'codeSystemName' => 'SNOMED-CT');
1338 $xml->self_codeCustom($arr);
1340 $arr = array('code' => 'completed');
1341 $xml->self_customTag('statusCode', $arr);
1343 $timeArr = array('low' => date('Ymd', strtotime($from_date)));
1344 $xml->add_entryEffectTime($timeArr);
1348 $xml->open_customTag('value', array('xsi:type'=>'CD', 'nullFlavor'=>'OTH'));
1350 $xml->self_customTag('translation', array('code'=>$PKey, 'displayName'=>$PVal, 'codeSystem'=>'2.16.840.1.113883.3.249.12', 'codeSystemName'=>'CMS Clinical Codes'));
1353 $xml->close_customTag();
1357 $xml->self_customTag('value', array('xsi:type' => 'CD', 'code' => $mainQrdaPayerCodeSendArr[$PKey], 'codeSystem' => '2.16.840.1.113883.3.221.5' , 'codeSystemName' => 'SOP', 'displayName' => $PVal));
1359 //entryRelationship Open
1360 $xml->open_customTag('entryRelationship', array('typeCode' => 'SUBJ', 'inversionInd' => 'true'));
1363 $xml->open_customTag('observation', array('classCode' => 'OBS', 'moodCode' => 'EVN'));
1365 $tempID = "2.16.840.1.113883.10.20.27.3.3";
1366 $xml->self_templateid($tempID);
1368 $tempID = "2.16.840.1.113883.10.20.27.3.24";
1369 $xml->self_templateid($tempID);
1371 $arr = array('code' => 'MSRAGG', 'displayName' => 'rate aggregation', 'codeSystem' => '2.16.840.1.113883.5.4', 'codeSystemName' => 'ActCode');
1372 $xml->self_codeCustom($arr);
1374 //$arr = array('code'=>'completed');
1375 //$xml->self_customTag('statusCode', $arr);
1377 $arr = array('xsi:type' => 'INT', 'value' => $payerCheckArr[$PVal]);
1378 $xml->self_customTag('value', $arr);
1380 $arr = array('code' => 'COUNT', 'displayName' => 'Count', 'codeSystem' => '2.16.840.1.113883.5.84', 'codeSystemName' => 'ObservationMethod');
1381 $xml->self_customTag('methodCode', $arr);
1384 $xml->close_customTag();
1386 //entryRelationship Close
1387 $xml->close_customTag();
1391 $xml->close_customTag();
1393 //entryRelationship Close
1394 $xml->close_customTag();
1397 ####################################################
1398 ####################################################
1399 //Payer Supplemental Data Element (CMS EP) END
1400 ####################################################
1401 ####################################################
1403 ######################################################################
1405 $arr = array('typeCode' => 'REFR');
1406 $xml->open_customTag('reference', $arr);
1408 //externalObservation Start
1409 $arr = array('classCode' => 'OBS', 'moodCode' => 'EVN');
1410 $xml->open_customTag('externalObservation', $arr);
1412 //Modified HQMF_ID for CQM IDS
1413 if (($row['cqm_nqf_code'] == "0421" )) {
1414 $refID = $preDefPopIdArr[$row['cqm_nqf_code']][$row['numerator_label']][$mainQrdaPopulationIncArr[$cqmKey]];
1415 } elseif (($row['cqm_nqf_code'] == "0024")) {
1416 $refID = $preDefPopIdArr[$row['cqm_nqf_code']][$row['population_label']][$row['numerator_label']][$mainQrdaPopulationIncArr[$cqmKey]];
1418 $refID = $preDefPopIdArr[$row['cqm_nqf_code']][$mainQrdaPopulationIncArr[$cqmKey]];
1425 $xml->self_customId($refID);
1427 //externalObservation Close
1428 $xml->close_customTag();
1431 $xml->close_customTag();
1432 ########################################################################
1435 $xml->close_customTag();
1437 $xml->close_loopComponent();
1438 ############### Initial patient population template END#####################
1441 //Multiple Numerator Handling
1442 if (in_array($row['cqm_nqf_code'], $multNumNQFArr)) {
1443 //Skipping Multiple Numerator(s)
1444 if (in_array($row['cqm_nqf_code'], $multNumNQFArr)) {
1445 $skipMultNumArr[$row['cqm_nqf_code']] = true;
1448 if ($dataChkArr[$row['cqm_nqf_code']] == $countNumNQFArr[$row['cqm_nqf_code']]) {
1450 $xml->close_customTag();
1451 $xml->close_entry();
1455 $xml->close_customTag();
1456 $xml->close_entry();
1459 ###########################################################
1465 #######################################################################
1466 ######################### QUALITY MEASURES END ########################
1467 #######################################################################
1470 $xml->close_section();
1472 $xml->close_loopComponent();
1474 ##################### LOOP Component(s) END ########################
1476 $xml->close_structuredBody();
1477 ############### Structure Body Close #######################
1479 $xml->close_mainComponent();
1480 ############### Main Component Close #######################
1482 //Close Main Clinical Document
1483 $xml->close_clinicaldocument();
1486 //QRDA File Download Folder in site/cqm_qrda folder
1487 $qrda_fname = "QRDA_III_" . date("YmdHis") . ".xml";
1488 $qrda_file_path = $GLOBALS['OE_SITE_DIR'] . "/documents/cqm_qrda/";
1489 if (!file_exists($qrda_file_path)) {
1490 mkdir($qrda_file_path, 0777, true);
1493 $qrda_file_name = $qrda_file_path . $qrda_fname;
1494 $fileQRDAOPen = fopen($qrda_file_name, "w");
1495 fwrite($fileQRDAOPen, trim($xml->getXml()));
1496 fclose($fileQRDAOPen);
1501 <?php Header
::setupHeader('opener'); ?
>
1502 <title
><?php
echo xlt('Export QRDA Report'); ?
></title
>
1506 function closeme() {
1513 <p
class="text"><?php
echo xlt('The exported data appears in the text area below. You can copy and paste this into an email or to any other desired destination (or) download the below link.'); ?
></p
>
1518 <a href
="qrda_download.php?qrda_fname=<?php echo attr_url($qrda_fname); ?>&csrf_token_form=<?php echo attr_url(CsrfUtils::collectCsrfToken()); ?>"><?php
echo xlt("Download QRDA Category III File");?
></a
>
1520 <textarea rows
='50' cols
='500' style
='width:95%' readonly
>
1521 <?php
echo trim($xml->getXml()); ?
>
1524 <p
><input type
='button' value
='<?php echo xla('Close
'); ?>' onclick
='closeme();' /></p
>