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>;.
21 * @link http://www.open-emr.org
25 class QRDAXml
extends XmlWriterOemr
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()
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));
64 $this->emptyelement('id', array('root'=>$this->unique_id
));
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'));
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'));
117 function open_recordTarget()
119 $this->push('recordTarget');
122 function close_recordTarget()
127 function open_author()
129 $this->push('author');
132 function close_author()
137 function self_authorTime($value)
139 $this->emptyelement('time', array('value'=>$value));
142 function open_assignAuthor()
144 $this->push('assignedAuthor');
147 function close_assignAuthor()
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'));
166 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
169 $this->add_facilAddress($facilArr);
173 function open_custodian()
175 $this->push('custodian');
178 function close_custodian()
183 function open_assgnCustodian()
185 $this->push('assignedCustodian');
188 function close_assgnCustodian()
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'));
206 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
209 $this->add_facilAddress($facilArr);
213 function open_infoRecipient()
215 $this->push('informationRecipient');
218 function close_infoRecipient()
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();
235 function open_legalAuthenticator()
237 $this->push('legalAuthenticator');
240 function close_legalAuthenticator()
245 function self_legalSignCode()
247 $this->emptyelement('signatureCode', array('code'=>'S'));
251 function open_assignedEntity()
253 $this->push('assignedEntity');
256 function close_assignedEntity()
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();
271 $this->element('name', $name);
273 $this->emptyelement('name');
279 function open_participant_data($code_type)
281 $this->push('participant', array('typeCode'=>$code_type));
284 function close_participant_data()
289 function open_assocEntityData($class_code)
291 $this->push('associatedEntity', array('classCode'=>$class_code));
294 function close_assocEntityData()
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']);
321 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
324 if ($addrArr['city'] != "") {
325 $this->element('city', $addrArr['city']);
327 $this->emptyelement('city', array("nullFlavor" => "UNK"));
330 if ($addrArr['state'] != "") {
331 $this->element('state', $addrArr['state']);
333 $this->emptyelement('state', array("nullFlavor" => "UNK"));
337 if ($addrArr['postal_code'] != "") {
338 $this->element('postalCode', $addrArr['postal_code']);
340 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
343 if ($addrArr['country_code'] != "") {
344 $this->element('country', $addrArr['country_code']);
346 $this->emptyelement('country', array("nullFlavor" => "UNK"));
352 function open_mainComponent()
354 $this->push('component');
357 function close_mainComponent()
362 function open_structuredBody()
364 $this->push('structuredBody');
367 function close_structuredBody()
372 function open_loopComponent()
374 $this->push('component');
377 function close_loopComponent()
382 function open_section()
384 $this->push('section');
387 function close_section()
392 function self_codeCustom($arr)
394 $this->emptyelement('code', $arr);
402 function close_text()
412 function close_list()
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));
427 $this->push('entry');
431 function close_entry()
436 function open_act($arr)
438 $this->push('act', $arr);
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']));
458 function open_customTag($ele, $arr = array())
460 if (count($arr) > 0) {
461 $this->push($ele, $arr);
467 function close_customTag()
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)
504 $this->element('given', $nameArr['fname']);
505 $this->element('family', $nameArr['lname']);
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']);
520 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
523 if ($addrArr['city'] != "") {
524 $this->element('city', $addrArr['city']);
526 $this->emptyelement('city', array("nullFlavor" => "UNK"));
529 if ($addrArr['state'] != "") {
530 $this->element('state', $addrArr['state']);
532 $this->emptyelement('state', array("nullFlavor" => "UNK"));
535 if ($addrArr['postal_code'] != "") {
536 $this->element('postalCode', $addrArr['postal_code']);
538 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
541 if ($addrArr['country_code'] != "") {
542 $this->element('country', $addrArr['country_code']);
544 $this->emptyelement('country', array("nullFlavor" => "UNK"));
551 function add_patName($nameArr)
554 $this->element('given', $nameArr['fname']);
555 $this->element('family', $nameArr['lname']);
559 function add_userAddress($addrArr)
562 $this->push('addr', array('use' => 'WP'));
563 if ($addrArr['street'] != "") {
564 $this->element('streetAddressLine', $addrArr['street']);
566 $this->emptyelement('streetAddressLine', array("nullFlavor" => "UNK"));
569 if ($addrArr['city'] != "") {
570 $this->element('city', $addrArr['city']);
572 $this->emptyelement('city', array("nullFlavor" => "UNK"));
575 if ($addrArr['state'] != "") {
576 $this->element('state', $addrArr['state']);
578 $this->emptyelement('state', array("nullFlavor" => "UNK"));
581 if ($addrArr['postal_code'] != "") {
582 $this->element('postalCode', $addrArr['postal_code']);
584 $this->emptyelement('postalCode', array("nullFlavor" => "UNK"));
587 if ($addrArr['country_code'] != "") {
588 $this->element('country', $addrArr['country_code']);
590 $this->emptyelement('country', array("nullFlavor" => "UNK"));
596 function add_entryTime($arr)
599 $this->emptyelement('low', array('value'=>$arr['low']));
600 if (isset($arr['high'])) {
601 $this->emptyelement('high', array('value'=>$arr['high']));
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']));
614 $this->emptyelement('high', array('nullFlavor'=>'NI'));
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']));
628 $this->emptyelement('high', array('nullFlavor'=>'NI'));