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>;.
22 * @link https://www.open-emr.org
26 class QRDAXml
extends XmlWriterOemr
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()
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));
65 $this->emptyelement('id', array('root' => $this->unique_id
));
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'));
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'));
118 function open_recordTarget()
120 $this->push('recordTarget');
123 function close_recordTarget()
128 function open_author()
130 $this->push('author');
133 function close_author()
138 function self_authorTime($value)
140 $this->emptyelement('time', array('value' => $value));
143 function open_assignAuthor()
145 $this->push('assignedAuthor');
148 function close_assignAuthor()
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'));
167 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
170 $this->add_facilAddress($facilArr);
174 function open_custodian()
176 $this->push('custodian');
179 function close_custodian()
184 function open_assgnCustodian()
186 $this->push('assignedCustodian');
189 function close_assgnCustodian()
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'));
207 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
210 $this->add_facilAddress($facilArr);
214 function open_infoRecipient()
216 $this->push('informationRecipient');
219 function close_infoRecipient()
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();
236 function open_legalAuthenticator()
238 $this->push('legalAuthenticator');
241 function close_legalAuthenticator()
246 function self_legalSignCode()
248 $this->emptyelement('signatureCode', array('code' => 'S'));
252 function open_assignedEntity()
254 $this->push('assignedEntity');
257 function close_assignedEntity()
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();
272 $this->element('name', $name);
274 $this->emptyelement('name');
280 function open_participant_data($code_type)
282 $this->push('participant', array('typeCode' => $code_type));
285 function close_participant_data()
290 function open_assocEntityData($class_code)
292 $this->push('associatedEntity', array('classCode' => $class_code));
295 function close_assocEntityData()
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']);
322 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
325 if ($addrArr['city'] != "") {
326 $this->element('city', $addrArr['city']);
328 $this->emptyelement('city', array("nullFlavor" => "UNK"));
331 if ($addrArr['state'] != "") {
332 $this->element('state', $addrArr['state']);
334 $this->emptyelement('state', array("nullFlavor" => "UNK"));
338 if ($addrArr['postal_code'] != "") {
339 $this->element('postalCode', $addrArr['postal_code']);
341 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
344 if ($addrArr['country_code'] != "") {
345 $this->element('country', $addrArr['country_code']);
347 $this->emptyelement('country', array("nullFlavor" => "UNK"));
353 function open_mainComponent()
355 $this->push('component');
358 function close_mainComponent()
363 function open_structuredBody()
365 $this->push('structuredBody');
368 function close_structuredBody()
373 function open_loopComponent()
375 $this->push('component');
378 function close_loopComponent()
383 function open_section()
385 $this->push('section');
388 function close_section()
393 function self_codeCustom($arr)
395 $this->emptyelement('code', $arr);
403 function close_text()
413 function close_list()
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));
428 $this->push('entry');
432 function close_entry()
437 function open_act($arr)
439 $this->push('act', $arr);
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']));
459 function open_customTag($ele, $arr = array())
461 if (count($arr) > 0) {
462 $this->push($ele, $arr);
468 function close_customTag()
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)
505 $this->element('given', $nameArr['fname']);
506 $this->element('family', $nameArr['lname']);
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']);
521 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
524 if ($addrArr['city'] != "") {
525 $this->element('city', $addrArr['city']);
527 $this->emptyelement('city', array("nullFlavor" => "UNK"));
530 if ($addrArr['state'] != "") {
531 $this->element('state', $addrArr['state']);
533 $this->emptyelement('state', array("nullFlavor" => "UNK"));
536 if ($addrArr['postal_code'] != "") {
537 $this->element('postalCode', $addrArr['postal_code']);
539 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
542 if ($addrArr['country_code'] != "") {
543 $this->element('country', $addrArr['country_code']);
545 $this->emptyelement('country', array("nullFlavor" => "UNK"));
552 function add_patName($nameArr)
555 $this->element('given', $nameArr['fname']);
556 $this->element('family', $nameArr['lname']);
560 function add_userAddress($addrArr)
563 $this->push('addr', array('use' => 'WP'));
564 if ($addrArr['street'] != "") {
565 $this->element('streetAddressLine', $addrArr['street']);
567 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
570 if ($addrArr['city'] != "") {
571 $this->element('city', $addrArr['city']);
573 $this->emptyelement('city', array("nullFlavor" => "UNK"));
576 if ($addrArr['state'] != "") {
577 $this->element('state', $addrArr['state']);
579 $this->emptyelement('state', array("nullFlavor" => "UNK"));
582 if ($addrArr['postal_code'] != "") {
583 $this->element('postalCode', $addrArr['postal_code']);
585 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
588 if ($addrArr['country_code'] != "") {
589 $this->element('country', $addrArr['country_code']);
591 $this->emptyelement('country', array("nullFlavor" => "UNK"));
597 function add_entryTime($arr)
600 $this->emptyelement('low', array('value' => $arr['low']));
601 if (isset($arr['high'])) {
602 $this->emptyelement('high', array('value' => $arr['high']));
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']));
615 $this->emptyelement('high', array('nullFlavor' => 'NI'));
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']));
629 $this->emptyelement('high', array('nullFlavor' => 'NI'));