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
24 require_once("XmlWriterOemr.class.php");
26 class QRDAXml
extends XmlWriterOemr
{
30 function __construct($nqf_code,$indent = ' ') {
31 $this->nqf_code
= $nqf_code;
32 parent
::__construct($indent);
36 function open_clinicaldocument() {
37 $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'));
40 function close_clinicaldocument() {
44 function self_realmcode(){
45 $this->emptyelement('realmCode', array('code'=>'US'));
48 function self_typeid(){
49 $this->emptyelement('typeId', array('root'=>'2.16.840.1.113883.1.3', 'extension'=>'POCD_HD000040'));
52 function self_templateid($id){
53 $this->emptyelement('templateId', array('root'=>$id));
57 $this->emptyelement('id', array('root'=>$this->unique_id
));
61 $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'));
64 function add_title($value) {
65 $this->element('title', $value);
68 function self_efftime($value){
69 $this->emptyelement('effectiveTime', array('value'=>$value));
72 function self_confidentcode(){
73 $this->emptyelement('confidentialityCode', array('codeSystem'=>'2.16.840.1.113883.5.25', 'code'=>'N', 'codeSystemName'=>'HL7Confidentiality'));
77 $this->emptyelement('languageCode', array('code'=>'en'));
80 function self_setid($id){
81 $this->emptyelement('setId', array('root'=>$id));
84 function self_version(){
85 $this->emptyelement('versionNumber', array('value'=>1));
89 function self_setpatientRoleid(){
90 $this->emptyelement('id', array('nullFlavor'=>'NA'));
93 function add_patientRole() {
94 $this->push('patientRole');
96 $this->emptyelement('id', array('nullFlavor'=>'NA'));
101 function open_recordTarget() {
102 $this->push('recordTarget');
105 function close_recordTarget() {
109 function open_author() {
110 $this->push('author');
113 function close_author() {
117 function self_authorTime($value){
118 $this->emptyelement('time', array('value'=>$value));
121 function open_assignAuthor() {
122 $this->push('assignedAuthor');
125 function close_assignAuthor() {
129 function self_customId($id){
130 $this->emptyelement('id', array('root'=>$id));
134 function add_authReprestOrginisation($facilArr) {
135 $this->push('representedOrganization');
136 $this->self_customTag('id', array('root' => '2.16.840.1.113883.19.5', 'extension' =>'223344'));
137 $this->element('name', $facilArr['name']);
138 if(!empty($facilArr['phone']))
139 $this->self_customTag('telecom', array('value' => $facilArr['phone'], 'use'=>'WP'));
141 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
142 $this->add_facilAddress($facilArr);
146 function open_custodian() {
147 $this->push('custodian');
150 function close_custodian() {
154 function open_assgnCustodian() {
155 $this->push('assignedCustodian');
158 function close_assgnCustodian() {
162 function self_reprsntCustId(){
163 $this->emptyelement('id', array('root'=>'2.16.840.1.113883.19.5'));
166 function add_represtCustodianOrginisation($facilArr) {
167 $this->push('representedCustodianOrganization');
168 $this->self_reprsntCustId();
169 $this->element('name', $facilArr['name']);
170 if(!empty($facilArr['phone']))
171 $this->self_customTag('telecom', array('value' => $facilArr['phone'], 'use'=>'WP'));
173 $this->self_customTag('telecom', array("nullFlavor" => "UNK"));
174 $this->add_facilAddress($facilArr);
178 function open_infoRecipient() {
179 $this->push('informationRecipient');
182 function close_infoRecipient() {
186 function self_intendedId(){
187 $this->emptyelement('id', array('root'=>'2.16.840.1.113883.3.249.7', 'extension'=>'CPC'));
190 function add_indententRecipient() {
191 $this->push('intendedRecipient');
192 $this->self_intendedId();
196 function open_legalAuthenticator() {
197 $this->push('legalAuthenticator');
200 function close_legalAuthenticator() {
204 function self_legalSignCode(){
205 $this->emptyelement('signatureCode', array('code'=>'S'));
209 function open_assignedEntity() {
210 $this->push('assignedEntity');
213 function close_assignedEntity() {
217 function self_represntOrgId(){
218 $this->emptyelement('id', array('root'=>'2.16.840.1.113883.19.5', 'extension'=>'223344'));
221 function add_represntOrgName($name) {
222 $this->push('representedOrganization');
223 $this->self_represntOrgId();
225 $this->element('name', $name);
227 $this->emptyelement('name');
231 function open_participant_data($code_type) {
232 $this->push('participant', array('typeCode'=>$code_type));
235 function close_participant_data() {
239 function open_assocEntityData($class_code) {
240 $this->push('associatedEntity', array('classCode'=>$class_code));
243 function close_assocEntityData() {
247 function self_participantCodeDevice(){
248 $this->emptyelement('code', array('code'=>'129465004', 'displayName'=>'medical record, device', 'codeSystem'=>'2.16.840.1.113883.6.96', 'codeSystemName'=>'SNOMED-CT'));
251 function self_participantCodeLocation(){
252 $this->emptyelement('code', array('code'=>'394730007', 'displayName'=>'healthcare related organization', 'codeSystem'=>'2.16.840.1.113883.6.96', 'codeSystemName'=>'SNOMED-CT'));
255 function self_particpantIdInfo($arr){
256 $this->emptyelement('id', $arr);
259 function add_facilAddress($addrArr) {
261 $this->push('addr',array("use" => "WP"));
262 if($addrArr['street'] != "")
263 $this->element('streetAddressLine', $addrArr['street']);
265 $this->emptyelement('streetAddressLine',array("nullFlavor" => "UNK"));
267 if($addrArr['city'] != "")
268 $this->element('city', $addrArr['city']);
270 $this->emptyelement('city',array("nullFlavor" => "UNK"));
272 if($addrArr['state'] != "")
273 $this->element('state', $addrArr['state']);
275 $this->emptyelement('state',array("nullFlavor" => "UNK"));
278 if($addrArr['postal_code'] != "")
279 $this->element('postalCode', $addrArr['postal_code']);
281 $this->emptyelement('postalCode',array("nullFlavor" => "UNK"));
283 if($addrArr['country_code'] != "")
284 $this->element('country', $addrArr['country_code']);
286 $this->emptyelement('country',array("nullFlavor" => "UNK"));
291 function open_mainComponent() {
292 $this->push('component');
295 function close_mainComponent() {
299 function open_structuredBody() {
300 $this->push('structuredBody');
303 function close_structuredBody() {
307 function open_loopComponent(){
308 $this->push('component');
311 function close_loopComponent() {
315 function open_section(){
316 $this->push('section');
319 function close_section() {
323 function self_codeCustom($arr){
324 $this->emptyelement('code', $arr);
327 function open_text(){
331 function close_text() {
335 function open_list(){
339 function close_list() {
343 function add_item($value) {
344 $this->element('item', $value);
347 function open_entry($code_type) {
349 $this->push('entry', array('typeCode'=>$code_type));
351 $this->push('entry');
354 function close_entry() {
358 function open_act($arr) {
359 $this->push('act', $arr);
362 function close_act() {
366 function add_entryEffectTime($arr) {
367 $this->push('effectiveTime');
368 $this->emptyelement('low', array('value'=>$arr['low']));
369 if(isset($arr['high'])){
370 $this->emptyelement('high', array('value'=>$arr['high']));
376 function open_customTag($ele, $arr = array()) {
378 $this->push($ele, $arr);
383 function close_customTag() {
387 function add_trElementsTitles() {
388 $this->element('th', 'eMeasure Title');
389 $this->element('th', 'Version neutral identifier');
390 $this->element('th', 'Version specific identifier');
393 function add_trElementsValues($arr = array()) {
394 $this->element('td', $arr[0]);
395 $this->element('td', $arr[1]);
396 $this->element('td', $arr[2]);
399 function innerContent($arr = array()) {
400 $this->xml
.= '<content styleCode="Bold">'.$arr['name'].'</content>:'.trim($arr['value']);
403 function self_customTag($tag, $arr){
404 $this->emptyelement($tag, $arr);
407 function textDispContent($content) {
408 $this->xml
.= '<text>'.$content.'</text>';
411 function add_providerName($nameArr) {
413 $this->element('given', $nameArr['fname']);
414 $this->element('family', $nameArr['lname']);
418 function add_facilName($facilName) {
419 $this->element('name', $facilName);
422 function add_patientAddress($addrArr) {
423 $this->push('addr',array('use' => 'WP'));
424 if($addrArr['street'] != "")
425 $this->element('streetAddressLine', $addrArr['street']);
427 $this->emptyelement('streetAddressLine',array("nullFlavor" => "UNK"));
429 if($addrArr['city'] != "")
430 $this->element('city', $addrArr['city']);
432 $this->emptyelement('city',array("nullFlavor" => "UNK"));
434 if($addrArr['state'] != "")
435 $this->element('state', $addrArr['state']);
437 $this->emptyelement('state',array("nullFlavor" => "UNK"));
439 if($addrArr['postal_code'] != "")
440 $this->element('postalCode', $addrArr['postal_code']);
442 $this->emptyelement('postalCode',array("nullFlavor" => "UNK"));
444 if($addrArr['country_code'] != "")
445 $this->element('country', $addrArr['country_code']);
447 $this->emptyelement('country',array("nullFlavor" => "UNK"));
454 function add_patName($nameArr) {
456 $this->element('given', $nameArr['fname']);
457 $this->element('family', $nameArr['lname']);
461 function add_userAddress($addrArr) {
463 $this->push('addr',array('use' => 'WP'));
464 if($addrArr['street'] != "")
465 $this->element('streetAddressLine', $addrArr['street']);
467 $this->emptyelement('streetAddressLine',array("nullFlavor" => "UNK"));
469 if($addrArr['city'] != "")
470 $this->element('city', $addrArr['city']);
472 $this->emptyelement('city',array("nullFlavor" => "UNK"));
474 if($addrArr['state'] != "")
475 $this->element('state', $addrArr['state']);
477 $this->emptyelement('state',array("nullFlavor" => "UNK"));
479 if($addrArr['postal_code'] != "")
480 $this->element('postalCode', $addrArr['postal_code']);
482 $this->emptyelement('postalCode',array("nullFlavor" => "UNK"));
484 if($addrArr['country_code'] != "")
485 $this->element('country', $addrArr['country_code']);
487 $this->emptyelement('country',array("nullFlavor" => "UNK"));
492 function add_entryTime($arr) {
494 $this->emptyelement('low', array('value'=>$arr['low']));
495 if(isset($arr['high'])){
496 $this->emptyelement('high', array('value'=>$arr['high']));
501 function add_entryEffectTimeQRDA($arr) {
502 $this->push('effectiveTime');
503 $this->emptyelement('low', array('value'=>$arr['low']));
504 if($arr['high'] != ""){
505 $this->emptyelement('high', array('value'=>$arr['high']));
507 $this->emptyelement('high', array('nullFlavor'=>'NI'));
512 function add_entryEffectTimeQRDAMed($arr) {
513 $arrPass = array('xsi:type' => 'IVL_TS');
514 $this->push('effectiveTime', $arrPass);
515 $this->emptyelement('low', array('value'=>$arr['low']));
516 if($arr['high'] != ""){
517 $this->emptyelement('high', array('value'=>$arr['high']));
519 $this->emptyelement('high', array('nullFlavor'=>'NI'));