Interim autoloaded library/classes via composer classmap, take 4. (#422)
[openemr.git] / library / classes / QRDAXml.class.php
blobcdecd9486a8c9d2280fcab924c76df909e952a04
1 <?php
2 /**
4 * This program implements the XML Writer to generate QRDA Category I (or) III 2014 XML.
6 * Copyright (C) 2015 Ensoftek, Inc
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @package OpenEMR
20 * @author Ensoftek
21 * @link http://www.open-emr.org
25 class QRDAXml extends XmlWriterOemr {
26 public $unique_id;
27 public $nqf_code;
29 function __construct($nqf_code,$indent = ' ') {
30 $this->nqf_code = $nqf_code;
31 parent::__construct($indent);
35 function open_clinicaldocument() {
36 $this->push('ClinicalDocument', array('xmlns'=>'urn:hl7-org:v3', 'xmlns:voc'=>'urn:hl7-org:v3/voc', 'xmlns:xsi'=>'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation'=>'urn:hl7-org:v3 http://xreg2.nist.gov:8080/hitspValidation/schema/','xmlns:sdtc' => 'urn:hl7-org:sdtc'));
39 function close_clinicaldocument() {
40 $this->pop();
43 function self_realmcode(){
44 $this->emptyelement('realmCode', array('code'=>'US'));
47 function self_typeid(){
48 $this->emptyelement('typeId', array('root'=>'2.16.840.1.113883.1.3', 'extension'=>'POCD_HD000040'));
51 function self_templateid($id){
52 $this->emptyelement('templateId', array('root'=>$id));
55 function self_id(){
56 $this->emptyelement('id', array('root'=>$this->unique_id));
59 function self_code(){
60 $this->emptyelement('code', array( 'code'=>'55184-6', 'codeSystem'=>'2.16.840.1.113883.6.1', 'codeSystemName'=>'LOINC', 'displayName'=>'Quality Reporting Document Architecture Calculated Summary Report'));
63 function add_title($value) {
64 $this->element('title', $value);
67 function self_efftime($value){
68 $this->emptyelement('effectiveTime', array('value'=>$value));
71 function self_confidentcode(){
72 $this->emptyelement('confidentialityCode', array('codeSystem'=>'2.16.840.1.113883.5.25', 'code'=>'N', 'codeSystemName'=>'HL7Confidentiality'));
75 function self_lang(){
76 $this->emptyelement('languageCode', array('code'=>'en'));
79 function self_setid($id){
80 $this->emptyelement('setId', array('root'=>$id));
83 function self_version(){
84 $this->emptyelement('versionNumber', array('value'=>1));
88 function self_setpatientRoleid(){
89 $this->emptyelement('id', array('nullFlavor'=>'NA'));
92 function add_patientRole() {
93 $this->push('patientRole');
95 $this->emptyelement('id', array('nullFlavor'=>'NA'));
97 $this->pop();
100 function open_recordTarget() {
101 $this->push('recordTarget');
104 function close_recordTarget() {
105 $this->pop();
108 function open_author() {
109 $this->push('author');
112 function close_author() {
113 $this->pop();
116 function self_authorTime($value){
117 $this->emptyelement('time', array('value'=>$value));
120 function open_assignAuthor() {
121 $this->push('assignedAuthor');
124 function close_assignAuthor() {
125 $this->pop();
128 function self_customId($id){
129 $this->emptyelement('id', array('root'=>$id));
133 function add_authReprestOrginisation($facilArr) {
134 $this->push('representedOrganization');
135 $this->self_customTag('id', array('root' => '2.16.840.1.113883.19.5', 'extension' =>'223344'));
136 $this->element('name', $facilArr['name']);
137 if(!empty($facilArr['phone']))
138 $this->self_customTag('telecom', array('value' => $facilArr['phone'], 'use'=>'WP'));
139 else
140 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
141 $this->add_facilAddress($facilArr);
142 $this->pop();
145 function open_custodian() {
146 $this->push('custodian');
149 function close_custodian() {
150 $this->pop();
153 function open_assgnCustodian() {
154 $this->push('assignedCustodian');
157 function close_assgnCustodian() {
158 $this->pop();
161 function self_reprsntCustId(){
162 $this->emptyelement('id', array('root'=>'2.16.840.1.113883.19.5'));
165 function add_represtCustodianOrginisation($facilArr) {
166 $this->push('representedCustodianOrganization');
167 $this->self_reprsntCustId();
168 $this->element('name', $facilArr['name']);
169 if(!empty($facilArr['phone']))
170 $this->self_customTag('telecom', array('value' => $facilArr['phone'], 'use'=>'WP'));
171 else
172 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
173 $this->add_facilAddress($facilArr);
174 $this->pop();
177 function open_infoRecipient() {
178 $this->push('informationRecipient');
181 function close_infoRecipient() {
182 $this->pop();
185 function self_intendedId(){
186 $this->emptyelement('id', array('root'=>'2.16.840.1.113883.3.249.7', 'extension'=>'CPC'));
189 function add_indententRecipient() {
190 $this->push('intendedRecipient');
191 $this->self_intendedId();
192 $this->pop();
195 function open_legalAuthenticator() {
196 $this->push('legalAuthenticator');
199 function close_legalAuthenticator() {
200 $this->pop();
203 function self_legalSignCode(){
204 $this->emptyelement('signatureCode', array('code'=>'S'));
208 function open_assignedEntity() {
209 $this->push('assignedEntity');
212 function close_assignedEntity() {
213 $this->pop();
216 function self_represntOrgId(){
217 $this->emptyelement('id', array('root'=>'2.16.840.1.113883.19.5', 'extension'=>'223344'));
220 function add_represntOrgName($name) {
221 $this->push('representedOrganization');
222 $this->self_represntOrgId();
223 if($name)
224 $this->element('name', $name);
225 else
226 $this->emptyelement('name');
227 $this->pop();
230 function open_participant_data($code_type) {
231 $this->push('participant', array('typeCode'=>$code_type));
234 function close_participant_data() {
235 $this->pop();
238 function open_assocEntityData($class_code) {
239 $this->push('associatedEntity', array('classCode'=>$class_code));
242 function close_assocEntityData() {
243 $this->pop();
246 function self_participantCodeDevice(){
247 $this->emptyelement('code', array('code'=>'129465004', 'displayName'=>'medical record, device', 'codeSystem'=>'2.16.840.1.113883.6.96', 'codeSystemName'=>'SNOMED-CT'));
250 function self_participantCodeLocation(){
251 $this->emptyelement('code', array('code'=>'394730007', 'displayName'=>'healthcare related organization', 'codeSystem'=>'2.16.840.1.113883.6.96', 'codeSystemName'=>'SNOMED-CT'));
254 function self_particpantIdInfo($arr){
255 $this->emptyelement('id', $arr);
258 function add_facilAddress($addrArr) {
260 $this->push('addr',array("use" => "WP"));
261 if($addrArr['street'] != "")
262 $this->element('streetAddressLine', $addrArr['street']);
263 else
264 $this->emptyelement('streetAddressLine',array("nullFlavor" => "UNK"));
266 if($addrArr['city'] != "")
267 $this->element('city', $addrArr['city']);
268 else
269 $this->emptyelement('city',array("nullFlavor" => "UNK"));
271 if($addrArr['state'] != "")
272 $this->element('state', $addrArr['state']);
273 else
274 $this->emptyelement('state',array("nullFlavor" => "UNK"));
277 if($addrArr['postal_code'] != "")
278 $this->element('postalCode', $addrArr['postal_code']);
279 else
280 $this->emptyelement('postalCode',array("nullFlavor" => "UNK"));
282 if($addrArr['country_code'] != "")
283 $this->element('country', $addrArr['country_code']);
284 else
285 $this->emptyelement('country',array("nullFlavor" => "UNK"));
287 $this->pop();
290 function open_mainComponent() {
291 $this->push('component');
294 function close_mainComponent() {
295 $this->pop();
298 function open_structuredBody() {
299 $this->push('structuredBody');
302 function close_structuredBody() {
303 $this->pop();
306 function open_loopComponent(){
307 $this->push('component');
310 function close_loopComponent() {
311 $this->pop();
314 function open_section(){
315 $this->push('section');
318 function close_section() {
319 $this->pop();
322 function self_codeCustom($arr){
323 $this->emptyelement('code', $arr);
326 function open_text(){
327 $this->push('text');
330 function close_text() {
331 $this->pop();
334 function open_list(){
335 $this->push('list');
338 function close_list() {
339 $this->pop();
342 function add_item($value) {
343 $this->element('item', $value);
346 function open_entry($code_type) {
347 if($code_type != "")
348 $this->push('entry', array('typeCode'=>$code_type));
349 else
350 $this->push('entry');
353 function close_entry() {
354 $this->pop();
357 function open_act($arr) {
358 $this->push('act', $arr);
361 function close_act() {
362 $this->pop();
365 function add_entryEffectTime($arr) {
366 $this->push('effectiveTime');
367 $this->emptyelement('low', array('value'=>$arr['low']));
368 if(isset($arr['high'])){
369 $this->emptyelement('high', array('value'=>$arr['high']));
371 $this->pop();
375 function open_customTag($ele, $arr = array()) {
376 if(count($arr) > 0)
377 $this->push($ele, $arr);
378 else
379 $this->push($ele);
382 function close_customTag() {
383 $this->pop();
386 function add_trElementsTitles() {
387 $this->element('th', 'eMeasure Title');
388 $this->element('th', 'Version neutral identifier');
389 $this->element('th', 'Version specific identifier');
392 function add_trElementsValues($arr = array()) {
393 $this->element('td', $arr[0]);
394 $this->element('td', $arr[1]);
395 $this->element('td', $arr[2]);
398 function innerContent($arr = array()) {
399 $this->xml .= '<content styleCode="Bold">'.$arr['name'].'</content>:'.trim($arr['value']);
402 function self_customTag($tag, $arr){
403 $this->emptyelement($tag, $arr);
406 function textDispContent($content) {
407 $this->xml .= '<text>'.$content.'</text>';
410 function add_providerName($nameArr) {
411 $this->push('name');
412 $this->element('given', $nameArr['fname']);
413 $this->element('family', $nameArr['lname']);
414 $this->pop();
417 function add_facilName($facilName) {
418 $this->element('name', $facilName);
421 function add_patientAddress($addrArr) {
422 $this->push('addr',array('use' => 'WP'));
423 if($addrArr['street'] != "")
424 $this->element('streetAddressLine', $addrArr['street']);
425 else
426 $this->emptyelement('streetAddressLine',array("nullFlavor" => "UNK"));
428 if($addrArr['city'] != "")
429 $this->element('city', $addrArr['city']);
430 else
431 $this->emptyelement('city',array("nullFlavor" => "UNK"));
433 if($addrArr['state'] != "")
434 $this->element('state', $addrArr['state']);
435 else
436 $this->emptyelement('state',array("nullFlavor" => "UNK"));
438 if($addrArr['postal_code'] != "")
439 $this->element('postalCode', $addrArr['postal_code']);
440 else
441 $this->emptyelement('postalCode',array("nullFlavor" => "UNK"));
443 if($addrArr['country_code'] != "")
444 $this->element('country', $addrArr['country_code']);
445 else
446 $this->emptyelement('country',array("nullFlavor" => "UNK"));
448 $this->pop();
453 function add_patName($nameArr) {
454 $this->push('name');
455 $this->element('given', $nameArr['fname']);
456 $this->element('family', $nameArr['lname']);
457 $this->pop();
460 function add_userAddress($addrArr) {
462 $this->push('addr',array('use' => 'WP'));
463 if($addrArr['street'] != "")
464 $this->element('streetAddressLine', $addrArr['street']);
465 else
466 $this->emptyelement('streetAddressLine',array("nullFlavor" => "UNK"));
468 if($addrArr['city'] != "")
469 $this->element('city', $addrArr['city']);
470 else
471 $this->emptyelement('city',array("nullFlavor" => "UNK"));
473 if($addrArr['state'] != "")
474 $this->element('state', $addrArr['state']);
475 else
476 $this->emptyelement('state',array("nullFlavor" => "UNK"));
478 if($addrArr['postal_code'] != "")
479 $this->element('postalCode', $addrArr['postal_code']);
480 else
481 $this->emptyelement('postalCode',array("nullFlavor" => "UNK"));
483 if($addrArr['country_code'] != "")
484 $this->element('country', $addrArr['country_code']);
485 else
486 $this->emptyelement('country',array("nullFlavor" => "UNK"));
488 $this->pop();
491 function add_entryTime($arr) {
492 $this->push('time');
493 $this->emptyelement('low', array('value'=>$arr['low']));
494 if(isset($arr['high'])){
495 $this->emptyelement('high', array('value'=>$arr['high']));
497 $this->pop();
500 function add_entryEffectTimeQRDA($arr) {
501 $this->push('effectiveTime');
502 $this->emptyelement('low', array('value'=>$arr['low']));
503 if($arr['high'] != ""){
504 $this->emptyelement('high', array('value'=>$arr['high']));
505 }else{
506 $this->emptyelement('high', array('nullFlavor'=>'NI'));
508 $this->pop();
511 function add_entryEffectTimeQRDAMed($arr) {
512 $arrPass = array('xsi:type' => 'IVL_TS');
513 $this->push('effectiveTime', $arrPass);
514 $this->emptyelement('low', array('value'=>$arr['low']));
515 if($arr['high'] != ""){
516 $this->emptyelement('high', array('value'=>$arr['high']));
517 }else{
518 $this->emptyelement('high', array('nullFlavor'=>'NI'));
520 $this->pop();