mysql 8 fixes (#1639)
[openemr.git] / library / classes / QRDAXml.class.php
blob90600ab8182b86c1fe2135f10f6ab51cf5098cb3
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
27 public $unique_id;
28 public $nqf_code;
30 function __construct($nqf_code, $indent = ' ')
32 $this->nqf_code = $nqf_code;
33 parent::__construct($indent);
37 function open_clinicaldocument()
39 $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'));
42 function close_clinicaldocument()
44 $this->pop();
47 function self_realmcode()
49 $this->emptyelement('realmCode', array('code'=>'US'));
52 function self_typeid()
54 $this->emptyelement('typeId', array('root'=>'2.16.840.1.113883.1.3', 'extension'=>'POCD_HD000040'));
57 function self_templateid($id)
59 $this->emptyelement('templateId', array('root'=>$id));
62 function self_id()
64 $this->emptyelement('id', array('root'=>$this->unique_id));
67 function self_code()
69 $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'));
72 function add_title($value)
74 $this->element('title', $value);
77 function self_efftime($value)
79 $this->emptyelement('effectiveTime', array('value'=>$value));
82 function self_confidentcode()
84 $this->emptyelement('confidentialityCode', array('codeSystem'=>'2.16.840.1.113883.5.25', 'code'=>'N', 'codeSystemName'=>'HL7Confidentiality'));
87 function self_lang()
89 $this->emptyelement('languageCode', array('code'=>'en'));
92 function self_setid($id)
94 $this->emptyelement('setId', array('root'=>$id));
97 function self_version()
99 $this->emptyelement('versionNumber', array('value'=>1));
103 function self_setpatientRoleid()
105 $this->emptyelement('id', array('nullFlavor'=>'NA'));
108 function add_patientRole()
110 $this->push('patientRole');
112 $this->emptyelement('id', array('nullFlavor'=>'NA'));
114 $this->pop();
117 function open_recordTarget()
119 $this->push('recordTarget');
122 function close_recordTarget()
124 $this->pop();
127 function open_author()
129 $this->push('author');
132 function close_author()
134 $this->pop();
137 function self_authorTime($value)
139 $this->emptyelement('time', array('value'=>$value));
142 function open_assignAuthor()
144 $this->push('assignedAuthor');
147 function close_assignAuthor()
149 $this->pop();
152 function self_customId($id)
154 $this->emptyelement('id', array('root'=>$id));
158 function add_authReprestOrginisation($facilArr)
160 $this->push('representedOrganization');
161 $this->self_customTag('id', array('root' => '2.16.840.1.113883.19.5', 'extension' =>'223344'));
162 $this->element('name', $facilArr['name']);
163 if (!empty($facilArr['phone'])) {
164 $this->self_customTag('telecom', array('value' => $facilArr['phone'], 'use'=>'WP'));
165 } else {
166 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
169 $this->add_facilAddress($facilArr);
170 $this->pop();
173 function open_custodian()
175 $this->push('custodian');
178 function close_custodian()
180 $this->pop();
183 function open_assgnCustodian()
185 $this->push('assignedCustodian');
188 function close_assgnCustodian()
190 $this->pop();
193 function self_reprsntCustId()
195 $this->emptyelement('id', array('root'=>'2.16.840.1.113883.19.5'));
198 function add_represtCustodianOrginisation($facilArr)
200 $this->push('representedCustodianOrganization');
201 $this->self_reprsntCustId();
202 $this->element('name', $facilArr['name']);
203 if (!empty($facilArr['phone'])) {
204 $this->self_customTag('telecom', array('value' => $facilArr['phone'], 'use'=>'WP'));
205 } else {
206 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
209 $this->add_facilAddress($facilArr);
210 $this->pop();
213 function open_infoRecipient()
215 $this->push('informationRecipient');
218 function close_infoRecipient()
220 $this->pop();
223 function self_intendedId()
225 $this->emptyelement('id', array('root'=>'2.16.840.1.113883.3.249.7', 'extension'=>'CPC'));
228 function add_indententRecipient()
230 $this->push('intendedRecipient');
231 $this->self_intendedId();
232 $this->pop();
235 function open_legalAuthenticator()
237 $this->push('legalAuthenticator');
240 function close_legalAuthenticator()
242 $this->pop();
245 function self_legalSignCode()
247 $this->emptyelement('signatureCode', array('code'=>'S'));
251 function open_assignedEntity()
253 $this->push('assignedEntity');
256 function close_assignedEntity()
258 $this->pop();
261 function self_represntOrgId()
263 $this->emptyelement('id', array('root'=>'2.16.840.1.113883.19.5', 'extension'=>'223344'));
266 function add_represntOrgName($name)
268 $this->push('representedOrganization');
269 $this->self_represntOrgId();
270 if ($name) {
271 $this->element('name', $name);
272 } else {
273 $this->emptyelement('name');
276 $this->pop();
279 function open_participant_data($code_type)
281 $this->push('participant', array('typeCode'=>$code_type));
284 function close_participant_data()
286 $this->pop();
289 function open_assocEntityData($class_code)
291 $this->push('associatedEntity', array('classCode'=>$class_code));
294 function close_assocEntityData()
296 $this->pop();
299 function self_participantCodeDevice()
301 $this->emptyelement('code', array('code'=>'129465004', 'displayName'=>'medical record, device', 'codeSystem'=>'2.16.840.1.113883.6.96', 'codeSystemName'=>'SNOMED-CT'));
304 function self_participantCodeLocation()
306 $this->emptyelement('code', array('code'=>'394730007', 'displayName'=>'healthcare related organization', 'codeSystem'=>'2.16.840.1.113883.6.96', 'codeSystemName'=>'SNOMED-CT'));
309 function self_particpantIdInfo($arr)
311 $this->emptyelement('id', $arr);
314 function add_facilAddress($addrArr)
317 $this->push('addr', array("use" => "WP"));
318 if ($addrArr['street'] != "") {
319 $this->element('streetAddressLine', $addrArr['street']);
320 } else {
321 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
324 if ($addrArr['city'] != "") {
325 $this->element('city', $addrArr['city']);
326 } else {
327 $this->emptyelement('city', array("nullFlavor" => "UNK"));
330 if ($addrArr['state'] != "") {
331 $this->element('state', $addrArr['state']);
332 } else {
333 $this->emptyelement('state', array("nullFlavor" => "UNK"));
337 if ($addrArr['postal_code'] != "") {
338 $this->element('postalCode', $addrArr['postal_code']);
339 } else {
340 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
343 if ($addrArr['country_code'] != "") {
344 $this->element('country', $addrArr['country_code']);
345 } else {
346 $this->emptyelement('country', array("nullFlavor" => "UNK"));
349 $this->pop();
352 function open_mainComponent()
354 $this->push('component');
357 function close_mainComponent()
359 $this->pop();
362 function open_structuredBody()
364 $this->push('structuredBody');
367 function close_structuredBody()
369 $this->pop();
372 function open_loopComponent()
374 $this->push('component');
377 function close_loopComponent()
379 $this->pop();
382 function open_section()
384 $this->push('section');
387 function close_section()
389 $this->pop();
392 function self_codeCustom($arr)
394 $this->emptyelement('code', $arr);
397 function open_text()
399 $this->push('text');
402 function close_text()
404 $this->pop();
407 function open_list()
409 $this->push('list');
412 function close_list()
414 $this->pop();
417 function add_item($value)
419 $this->element('item', $value);
422 function open_entry($code_type)
424 if ($code_type != "") {
425 $this->push('entry', array('typeCode'=>$code_type));
426 } else {
427 $this->push('entry');
431 function close_entry()
433 $this->pop();
436 function open_act($arr)
438 $this->push('act', $arr);
441 function close_act()
443 $this->pop();
446 function add_entryEffectTime($arr)
448 $this->push('effectiveTime');
449 $this->emptyelement('low', array('value'=>$arr['low']));
450 if (isset($arr['high'])) {
451 $this->emptyelement('high', array('value'=>$arr['high']));
454 $this->pop();
458 function open_customTag($ele, $arr = array())
460 if (count($arr) > 0) {
461 $this->push($ele, $arr);
462 } else {
463 $this->push($ele);
467 function close_customTag()
469 $this->pop();
472 function add_trElementsTitles()
474 $this->element('th', 'eMeasure Title');
475 $this->element('th', 'Version neutral identifier');
476 $this->element('th', 'Version specific identifier');
479 function add_trElementsValues($arr = array())
481 $this->element('td', $arr[0]);
482 $this->element('td', $arr[1]);
483 $this->element('td', $arr[2]);
486 function innerContent($arr = array())
488 $this->xml .= '<content styleCode="Bold">'.$arr['name'].'</content>:'.trim($arr['value']);
491 function self_customTag($tag, $arr)
493 $this->emptyelement($tag, $arr);
496 function textDispContent($content)
498 $this->xml .= '<text>'.$content.'</text>';
501 function add_providerName($nameArr)
503 $this->push('name');
504 $this->element('given', $nameArr['fname']);
505 $this->element('family', $nameArr['lname']);
506 $this->pop();
509 function add_facilName($facilName)
511 $this->element('name', $facilName);
514 function add_patientAddress($addrArr)
516 $this->push('addr', array('use' => 'WP'));
517 if ($addrArr['street'] != "") {
518 $this->element('streetAddressLine', $addrArr['street']);
519 } else {
520 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
523 if ($addrArr['city'] != "") {
524 $this->element('city', $addrArr['city']);
525 } else {
526 $this->emptyelement('city', array("nullFlavor" => "UNK"));
529 if ($addrArr['state'] != "") {
530 $this->element('state', $addrArr['state']);
531 } else {
532 $this->emptyelement('state', array("nullFlavor" => "UNK"));
535 if ($addrArr['postal_code'] != "") {
536 $this->element('postalCode', $addrArr['postal_code']);
537 } else {
538 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
541 if ($addrArr['country_code'] != "") {
542 $this->element('country', $addrArr['country_code']);
543 } else {
544 $this->emptyelement('country', array("nullFlavor" => "UNK"));
547 $this->pop();
551 function add_patName($nameArr)
553 $this->push('name');
554 $this->element('given', $nameArr['fname']);
555 $this->element('family', $nameArr['lname']);
556 $this->pop();
559 function add_userAddress($addrArr)
562 $this->push('addr', array('use' => 'WP'));
563 if ($addrArr['street'] != "") {
564 $this->element('streetAddressLine', $addrArr['street']);
565 } else {
566 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
569 if ($addrArr['city'] != "") {
570 $this->element('city', $addrArr['city']);
571 } else {
572 $this->emptyelement('city', array("nullFlavor" => "UNK"));
575 if ($addrArr['state'] != "") {
576 $this->element('state', $addrArr['state']);
577 } else {
578 $this->emptyelement('state', array("nullFlavor" => "UNK"));
581 if ($addrArr['postal_code'] != "") {
582 $this->element('postalCode', $addrArr['postal_code']);
583 } else {
584 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
587 if ($addrArr['country_code'] != "") {
588 $this->element('country', $addrArr['country_code']);
589 } else {
590 $this->emptyelement('country', array("nullFlavor" => "UNK"));
593 $this->pop();
596 function add_entryTime($arr)
598 $this->push('time');
599 $this->emptyelement('low', array('value'=>$arr['low']));
600 if (isset($arr['high'])) {
601 $this->emptyelement('high', array('value'=>$arr['high']));
604 $this->pop();
607 function add_entryEffectTimeQRDA($arr)
609 $this->push('effectiveTime');
610 $this->emptyelement('low', array('value'=>$arr['low']));
611 if ($arr['high'] != "") {
612 $this->emptyelement('high', array('value'=>$arr['high']));
613 } else {
614 $this->emptyelement('high', array('nullFlavor'=>'NI'));
617 $this->pop();
620 function add_entryEffectTimeQRDAMed($arr)
622 $arrPass = array('xsi:type' => 'IVL_TS');
623 $this->push('effectiveTime', $arrPass);
624 $this->emptyelement('low', array('value'=>$arr['low']));
625 if ($arr['high'] != "") {
626 $this->emptyelement('high', array('value'=>$arr['high']));
627 } else {
628 $this->emptyelement('high', array('nullFlavor'=>'NI'));
631 $this->pop();