fix: Update patient_tracker.php (#6595)
[openemr.git] / library / classes / QRDAXml.class.php
blob309410b5171dd99da9eff3e6766475feaa308e92
1 <?php
3 /**
5 * This program implements the XML Writer to generate QRDA Category I (or) III 2014 XML.
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 <https://opensource.org/licenses/gpl-license.php>;.
20 * @package OpenEMR
21 * @author Ensoftek
22 * @link https://www.open-emr.org
26 class QRDAXml extends XmlWriterOemr
28 public $unique_id;
29 public $nqf_code;
31 function __construct($nqf_code = '', $indent = ' ')
33 $this->nqf_code = $nqf_code;
34 parent::__construct($indent);
38 function open_clinicaldocument()
40 $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'));
43 function close_clinicaldocument()
45 $this->pop();
48 function self_realmcode()
50 $this->emptyelement('realmCode', array('code' => 'US'));
53 function self_typeid()
55 $this->emptyelement('typeId', array('root' => '2.16.840.1.113883.1.3', 'extension' => 'POCD_HD000040'));
58 function self_templateid($id)
60 $this->emptyelement('templateId', array('root' => $id));
63 function self_id()
65 $this->emptyelement('id', array('root' => $this->unique_id));
68 function self_code()
70 $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'));
73 function add_title($value)
75 $this->element('title', $value);
78 function self_efftime($value)
80 $this->emptyelement('effectiveTime', array('value' => $value));
83 function self_confidentcode()
85 $this->emptyelement('confidentialityCode', array('codeSystem' => '2.16.840.1.113883.5.25', 'code' => 'N', 'codeSystemName' => 'HL7Confidentiality'));
88 function self_lang()
90 $this->emptyelement('languageCode', array('code' => 'en'));
93 function self_setid($id)
95 $this->emptyelement('setId', array('root' => $id));
98 function self_version()
100 $this->emptyelement('versionNumber', array('value' => 1));
104 function self_setpatientRoleid()
106 $this->emptyelement('id', array('nullFlavor' => 'NA'));
109 function add_patientRole()
111 $this->push('patientRole');
113 $this->emptyelement('id', array('nullFlavor' => 'NA'));
115 $this->pop();
118 function open_recordTarget()
120 $this->push('recordTarget');
123 function close_recordTarget()
125 $this->pop();
128 function open_author()
130 $this->push('author');
133 function close_author()
135 $this->pop();
138 function self_authorTime($value)
140 $this->emptyelement('time', array('value' => $value));
143 function open_assignAuthor()
145 $this->push('assignedAuthor');
148 function close_assignAuthor()
150 $this->pop();
153 function self_customId($id)
155 $this->emptyelement('id', array('root' => $id));
159 function add_authReprestOrginisation($facilArr)
161 $this->push('representedOrganization');
162 $this->self_customTag('id', array('root' => '2.16.840.1.113883.19.5', 'extension' => '223344'));
163 $this->element('name', $facilArr['name']);
164 if (!empty($facilArr['phone'])) {
165 $this->self_customTag('telecom', array('value' => $facilArr['phone'], 'use' => 'WP'));
166 } else {
167 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
170 $this->add_facilAddress($facilArr);
171 $this->pop();
174 function open_custodian()
176 $this->push('custodian');
179 function close_custodian()
181 $this->pop();
184 function open_assgnCustodian()
186 $this->push('assignedCustodian');
189 function close_assgnCustodian()
191 $this->pop();
194 function self_reprsntCustId()
196 $this->emptyelement('id', array('root' => '2.16.840.1.113883.19.5'));
199 function add_represtCustodianOrginisation($facilArr)
201 $this->push('representedCustodianOrganization');
202 $this->self_reprsntCustId();
203 $this->element('name', $facilArr['name']);
204 if (!empty($facilArr['phone'])) {
205 $this->self_customTag('telecom', array('value' => $facilArr['phone'], 'use' => 'WP'));
206 } else {
207 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
210 $this->add_facilAddress($facilArr);
211 $this->pop();
214 function open_infoRecipient()
216 $this->push('informationRecipient');
219 function close_infoRecipient()
221 $this->pop();
224 function self_intendedId()
226 $this->emptyelement('id', array('root' => '2.16.840.1.113883.3.249.7', 'extension' => 'CPC'));
229 function add_indententRecipient()
231 $this->push('intendedRecipient');
232 $this->self_intendedId();
233 $this->pop();
236 function open_legalAuthenticator()
238 $this->push('legalAuthenticator');
241 function close_legalAuthenticator()
243 $this->pop();
246 function self_legalSignCode()
248 $this->emptyelement('signatureCode', array('code' => 'S'));
252 function open_assignedEntity()
254 $this->push('assignedEntity');
257 function close_assignedEntity()
259 $this->pop();
262 function self_represntOrgId()
264 $this->emptyelement('id', array('root' => '2.16.840.1.113883.19.5', 'extension' => '223344'));
267 function add_represntOrgName($name)
269 $this->push('representedOrganization');
270 $this->self_represntOrgId();
271 if ($name) {
272 $this->element('name', $name);
273 } else {
274 $this->emptyelement('name');
277 $this->pop();
280 function open_participant_data($code_type)
282 $this->push('participant', array('typeCode' => $code_type));
285 function close_participant_data()
287 $this->pop();
290 function open_assocEntityData($class_code)
292 $this->push('associatedEntity', array('classCode' => $class_code));
295 function close_assocEntityData()
297 $this->pop();
300 function self_participantCodeDevice()
302 $this->emptyelement('code', array('code' => '129465004', 'displayName' => 'medical record, device', 'codeSystem' => '2.16.840.1.113883.6.96', 'codeSystemName' => 'SNOMED-CT'));
305 function self_participantCodeLocation()
307 $this->emptyelement('code', array('code' => '394730007', 'displayName' => 'healthcare related organization', 'codeSystem' => '2.16.840.1.113883.6.96', 'codeSystemName' => 'SNOMED-CT'));
310 function self_particpantIdInfo($arr)
312 $this->emptyelement('id', $arr);
315 function add_facilAddress($addrArr)
318 $this->push('addr', array("use" => "WP"));
319 if ($addrArr['street'] != "") {
320 $this->element('streetAddressLine', $addrArr['street']);
321 } else {
322 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
325 if ($addrArr['city'] != "") {
326 $this->element('city', $addrArr['city']);
327 } else {
328 $this->emptyelement('city', array("nullFlavor" => "UNK"));
331 if ($addrArr['state'] != "") {
332 $this->element('state', $addrArr['state']);
333 } else {
334 $this->emptyelement('state', array("nullFlavor" => "UNK"));
338 if ($addrArr['postal_code'] != "") {
339 $this->element('postalCode', $addrArr['postal_code']);
340 } else {
341 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
344 if ($addrArr['country_code'] != "") {
345 $this->element('country', $addrArr['country_code']);
346 } else {
347 $this->emptyelement('country', array("nullFlavor" => "UNK"));
350 $this->pop();
353 function open_mainComponent()
355 $this->push('component');
358 function close_mainComponent()
360 $this->pop();
363 function open_structuredBody()
365 $this->push('structuredBody');
368 function close_structuredBody()
370 $this->pop();
373 function open_loopComponent()
375 $this->push('component');
378 function close_loopComponent()
380 $this->pop();
383 function open_section()
385 $this->push('section');
388 function close_section()
390 $this->pop();
393 function self_codeCustom($arr)
395 $this->emptyelement('code', $arr);
398 function open_text()
400 $this->push('text');
403 function close_text()
405 $this->pop();
408 function open_list()
410 $this->push('list');
413 function close_list()
415 $this->pop();
418 function add_item($value)
420 $this->element('item', $value);
423 function open_entry($code_type = '')
425 if ($code_type != "") {
426 $this->push('entry', array('typeCode' => $code_type));
427 } else {
428 $this->push('entry');
432 function close_entry()
434 $this->pop();
437 function open_act($arr)
439 $this->push('act', $arr);
442 function close_act()
444 $this->pop();
447 function add_entryEffectTime($arr)
449 $this->push('effectiveTime');
450 $this->emptyelement('low', array('value' => $arr['low']));
451 if (isset($arr['high'])) {
452 $this->emptyelement('high', array('value' => $arr['high']));
455 $this->pop();
459 function open_customTag($ele, $arr = array())
461 if (count($arr) > 0) {
462 $this->push($ele, $arr);
463 } else {
464 $this->push($ele);
468 function close_customTag()
470 $this->pop();
473 function add_trElementsTitles()
475 $this->element('th', 'eMeasure Title');
476 $this->element('th', 'Version neutral identifier');
477 $this->element('th', 'Version specific identifier');
480 function add_trElementsValues($arr = array())
482 $this->element('td', $arr[0]);
483 $this->element('td', $arr[1]);
484 $this->element('td', $arr[2]);
487 function innerContent($arr = array())
489 $this->xml .= '<content styleCode="Bold">' . $arr['name'] . '</content>:' . trim($arr['value']);
492 function self_customTag($tag, $arr)
494 $this->emptyelement($tag, $arr);
497 function textDispContent($content)
499 $this->xml .= '<text>' . $content . '</text>';
502 function add_providerName($nameArr)
504 $this->push('name');
505 $this->element('given', $nameArr['fname']);
506 $this->element('family', $nameArr['lname']);
507 $this->pop();
510 function add_facilName($facilName)
512 $this->element('name', $facilName);
515 function add_patientAddress($addrArr)
517 $this->push('addr', array('use' => 'WP'));
518 if ($addrArr['street'] != "") {
519 $this->element('streetAddressLine', $addrArr['street']);
520 } else {
521 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
524 if ($addrArr['city'] != "") {
525 $this->element('city', $addrArr['city']);
526 } else {
527 $this->emptyelement('city', array("nullFlavor" => "UNK"));
530 if ($addrArr['state'] != "") {
531 $this->element('state', $addrArr['state']);
532 } else {
533 $this->emptyelement('state', array("nullFlavor" => "UNK"));
536 if ($addrArr['postal_code'] != "") {
537 $this->element('postalCode', $addrArr['postal_code']);
538 } else {
539 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
542 if ($addrArr['country_code'] != "") {
543 $this->element('country', $addrArr['country_code']);
544 } else {
545 $this->emptyelement('country', array("nullFlavor" => "UNK"));
548 $this->pop();
552 function add_patName($nameArr)
554 $this->push('name');
555 $this->element('given', $nameArr['fname']);
556 $this->element('family', $nameArr['lname']);
557 $this->pop();
560 function add_userAddress($addrArr)
563 $this->push('addr', array('use' => 'WP'));
564 if ($addrArr['street'] != "") {
565 $this->element('streetAddressLine', $addrArr['street']);
566 } else {
567 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
570 if ($addrArr['city'] != "") {
571 $this->element('city', $addrArr['city']);
572 } else {
573 $this->emptyelement('city', array("nullFlavor" => "UNK"));
576 if ($addrArr['state'] != "") {
577 $this->element('state', $addrArr['state']);
578 } else {
579 $this->emptyelement('state', array("nullFlavor" => "UNK"));
582 if ($addrArr['postal_code'] != "") {
583 $this->element('postalCode', $addrArr['postal_code']);
584 } else {
585 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
588 if ($addrArr['country_code'] != "") {
589 $this->element('country', $addrArr['country_code']);
590 } else {
591 $this->emptyelement('country', array("nullFlavor" => "UNK"));
594 $this->pop();
597 function add_entryTime($arr)
599 $this->push('time');
600 $this->emptyelement('low', array('value' => $arr['low']));
601 if (isset($arr['high'])) {
602 $this->emptyelement('high', array('value' => $arr['high']));
605 $this->pop();
608 function add_entryEffectTimeQRDA($arr)
610 $this->push('effectiveTime');
611 $this->emptyelement('low', array('value' => $arr['low']));
612 if ($arr['high'] != "") {
613 $this->emptyelement('high', array('value' => $arr['high']));
614 } else {
615 $this->emptyelement('high', array('nullFlavor' => 'NI'));
618 $this->pop();
621 function add_entryEffectTimeQRDAMed($arr)
623 $arrPass = array('xsi:type' => 'IVL_TS');
624 $this->push('effectiveTime', $arrPass);
625 $this->emptyelement('low', array('value' => $arr['low']));
626 if ($arr['high'] != "") {
627 $this->emptyelement('high', array('value' => $arr['high']));
628 } else {
629 $this->emptyelement('high', array('nullFlavor' => 'NI'));
632 $this->pop();