Example #1
0
    public static function populate(CCD $base, SimpleXMLElement $xml)
    {
        $component = $xml->addChild('component');
        $section = $component->addChild('section');
        $templateId = $section->addChild('templateId');
        $templateId->addAttribute('root', '2.16.840.1.113883.3.88.11.83.112');
        $templateId->addAttribute('assigningAuthorityName', 'HITSP/C83');
        $templateId = $section->addChild('templateId');
        $templateId->addAttribute('root', '1.3.6.1.4.1.19376.1.5.3.1.3.19');
        $templateId->addAttribute('assigningAuthorityName', 'IHE PCC');
        $templateId = $section->addChild('templateId');
        $templateId->addAttribute('root', '2.16.840.1.113883.10.20.1.8');
        $templateId->addAttribute('assigningAuthorityName', 'HL7 CCD');
        // <!-- Medications section template -->
        $code = $section->addChild('code');
        $code->addAttribute('code', '10160-0');
        $code->addAttribute('codeSystem', '2.16.840.1.113883.6.1');
        $code->addAttribute('codeSystemName', 'LOINC');
        $code->addAttribute('displayName', 'History of medication use');
        $section->addChild('title', 'Medications');
        $medications = array();
        $rows = array();
        $filters = array('patientId' => $base->patient->personId);
        $base->setFiltersDateRange($filters);
        $iterator = new MedicationIterator();
        $iterator->setFilter($filters);
        foreach ($iterator as $medication) {
            $medications[] = $medication;
            $datePrescribed = '&#160;';
            if ($medication->datePrescribed != '0000-00-00 00:00:00') {
                $datePrescribed = date('M d, Y', strtotime($medication->datePrescribed));
            }
            $baseMed24 = $medication->baseMed24;
            //$status = ($medication->status != 'Discontinued')?'Active':'Discontinued';
            $rows[] = array('rxnorm' => $baseMed24->rxnorm_cuid, 'product' => 'Medication', 'medication' => html_convert_entities($medication->description), 'generic' => html_convert_entities($baseMed24->fdaDrugname), 'brand' => html_convert_entities($baseMed24->tradename), 'instructions' => html_convert_entities($medication->directions), 'strength' => html_convert_entities($medication->strength), 'dose' => html_convert_entities($medication->dose), 'route' => html_convert_entities($medication->route), 'frequency' => html_convert_entities($medication->schedule), 'date' => $datePrescribed, 'status' => html_convert_entities($medication->displayStatus));
        }
        $text = $section->addChild('text');
        if ($rows) {
            $table = $text->addChild('table');
            $thead = $table->addChild('thead');
            $tr = $thead->addChild('tr');
            $tr->addChild('th', 'RxNorm Code');
            $tr->addChild('th', 'Product');
            $tr->addChild('th', 'Medication');
            $tr->addChild('th', 'Generic Name');
            $tr->addChild('th', 'Brand Name');
            $tr->addChild('th', 'Instructions');
            $tr->addChild('th', 'Strength');
            $tr->addChild('th', 'Dose');
            $tr->addChild('th', 'Route');
            $tr->addChild('th', 'Frequency');
            $tr->addChild('th', 'Date Started');
            $tr->addChild('th', 'Status');
            $tbody = $table->addChild('tbody');
            foreach ($rows as $row) {
                $tr = $tbody->addChild('tr');
                $tr->addChild('td', $row['rxnorm']);
                $tr->addChild('td', $row['product']);
                $tr->addChild('td', $row['medication']);
                $tr->addChild('td', $row['generic']);
                $tr->addChild('td', $row['brand']);
                $tr->addChild('td', $row['instructions']);
                $tr->addChild('td', $row['strength']);
                $tr->addChild('td', $row['dose']);
                $tr->addChild('td', $row['route']);
                $tr->addChild('td', $row['frequency']);
                $tr->addChild('td', $row['date']);
                $tr->addChild('td', $row['status']);
            }
        }
        foreach ($medications as $medication) {
            $quantity = '';
            if (strlen($medication->strength) > 0 && strlen($medication->unit) > 0) {
                $strength = explode(';', $medication->strength);
                $strength = str_replace(',', '', $strength[0]);
                $unit = explode(';', $medication->unit);
                if ($strength) {
                    $quantity = '<quantity value="' . $strength . '" unit="' . preg_replace('/ /', '', strtolower($unit[0])) . '"/>';
                }
            }
            $status = $medication->displayStatus;
            $description = html_convert_entities($medication->description);
            $entry = '<substanceAdministration classCode="SBADM" moodCode="EVN">
				<templateId root="2.16.840.1.113883.3.88.11.83.8" assigningAuthorityName="HITSP C83"/>
				<templateId root="2.16.840.1.113883.10.20.1.24" assigningAuthorityName="CCD"/>
				<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7" assigningAuthorityName="IHE PCC"/>
				<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.1" assigningAuthorityName="IHE PCC"/>
				<!--Medication activity template -->
				<id root="' . NSDR::create_guid() . '"/>
				<statusCode code="completed"/>
				<effectiveTime xsi:type="IVL_TS">
					<low nullFlavor="UNK"/>
					<high nullFlavor="UNK"/>
				</effectiveTime>
				<effectiveTime xsi:type="PIVL_TS" institutionSpecified="false" operator="A">
					<period value="24" unit="h"/>
				</effectiveTime>
				<routeCode code="C38288" displayName="Oral" codeSystem="2.16.840.1.113883.3.26.1.1" codeSystemName="FDA RouteOfAdministration">
					<!--IHE/PCC recommends that the routeCode be taken from the HL7 RouteOfAdministration code system. However, HITSP/C32, C83 and C80 recommend that for the U.S. Realm it be taken from the FDA RouteOfAdministration code system.-->
					<translation displayName="Swallow, oral" code="PO" codeSystemName="HL7 RouteOfAdministration" codeSystem="2.16.840.1.113883.5.112"/>
				</routeCode>
				<doseQuantity value="1"/>
				<rateQuantity nullFlavor="NA"/>
				<consumable>
					<manufacturedProduct>
						<templateId root="2.16.840.1.113883.3.88.11.83.8.2" assigningAuthorityName="HITSP C83"/>
						<templateId root="2.16.840.1.113883.10.20.1.53" assigningAuthorityName="CCD"/>
						<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.2" assigningAuthorityName="IHE PCC"/>
						<!-- Product template -->
						<manufacturedMaterial>
							<code code="309362" codeSystem="2.16.840.1.113883.6.88" displayName="' . $description . '">
								<originalText>' . $description . '<reference/>
								</originalText>
								<translation code="174742" codeSystem="2.16.840.1.113883.6.88" displayName="' . $description . '" codeSystemName="RxNorm"/>
							</code>
							<name>Plavix</name>
						</manufacturedMaterial>
					</manufacturedProduct>
				</consumable>
				<entryRelationship typeCode="REFR">
					<observation classCode="OBS" moodCode="EVN">
						<templateId root="2.16.840.1.113883.10.20.1.47"/>
						<code code="33999-4" displayName="Status" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
						<value xsi:type="CE" code="55561003" displayName="' . $status . '" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT"/>
					</observation>
				</entryRelationship>
				<entryRelationship typeCode="REFR">
					<supply classCode="SPLY" moodCode="INT">
						<templateId root="2.16.840.1.113883.10.20.1.34" assigningAuthorityName="CCD"/>
						<templateId root="2.16.840.1.113883.3.88.11.83.8.3" assigningAuthorityName="HITSP C83"/>
						<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.3" assigningAuthorityName="IHE PCC"/>
						<id/>
						<statusCode code="completed"/>
						<effectiveTime xsi:type="IVL_TS">
							<low value="20020101"/>
							<high nullFlavor="UNK"/>
						</effectiveTime>
						<repeatNumber value="1"/>' . $quantity . '
					</supply>
				</entryRelationship>
				<entryRelationship typeCode="SUBJ">
					<observation classCode="OBS" moodCode="EVN">
						<templateId root="2.16.840.1.113883.3.88.11.83.8.1" assigningAuthorityName="HITSP C83"/>
						<code code="73639000" codeSystem="2.16.840.1.113883.6.96" displayName="Prescription Drug"/>
					</observation>
				</entryRelationship>
			</substanceAdministration>';
            $entry = $section->addChild('entry', $entry);
            $entry->addAttribute('typeCode', 'DRIV');
        }
    }
Example #2
0
 public function populateEncounters(SimpleXMLElement $xml)
 {
     $component = $xml->addChild('component');
     $section = $component->addChild('section');
     $templateId = $section->addChild('templateId');
     $templateId->addAttribute('root', '2.16.840.1.113883.10.20.1.3');
     // <!-- Encounters section template -->
     $code = $section->addChild('code');
     $code->addAttribute('code', '46240-8');
     $code->addAttribute('codeSystem', '2.16.840.1.113883.6.1');
     $section->addChild('title', 'Encounters');
     if ($this->visit !== null) {
         $visitIterator = array($this->visit);
     } else {
         $visitIterator = new VisitIterator();
         $visitIterator->setFilters(array('patientId' => $this->_patientId));
     }
     $rows = array();
     foreach ($visitIterator as $visit) {
         $building = new Building();
         $building->buildingId = $visit->buildingId;
         $building->populate();
         $appointment = new Appointment();
         $appointment->appointmentId = $visit->appointmentId;
         $appointment->populate();
         $rows[] = array('encounter' => html_convert_entities($appointment->title), 'location' => html_convert_entities($building->displayName), 'date' => date('M d, Y', strtotime($visit->dateOfTreatment)));
     }
     $text = $section->addChild('text');
     if ($rows) {
         $table = $text->addChild('table');
         $thead = $table->addChild('thead');
         $tr = $thead->addChild('tr');
         $tr->addChild('th', 'Encounter');
         $tr->addChild('th', 'Location');
         $tr->addChild('th', 'Date');
         $tbody = $table->addChild('tbody');
         foreach ($rows as $row) {
             $tr = $tbody->addChild('tr');
             $tr->addChild('td', $row['encounter']);
             $tr->addChild('td', $row['location']);
             $tr->addChild('td', $row['date']);
         }
     }
 }
Example #3
0
 function get_file_contents($url)
 {
     $cache_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cache';
     foreach (glob($cache_path . DIRECTORY_SEPARATOR . "*.dat") as $file_name) {
         if (time() - $this->ttl > filemtime($file_name)) {
             unlink($file_name);
         }
     }
     if ($cache_file = sprintf('%s/%08X.dat', $cache_path, crc32($url))) {
         $cache_exists = file_exists($cache_file);
         if ($this->ttl != '' && $cache_exists && filemtime($cache_file) > time() - $this->ttl) {
             $cached = implode('', file($cache_file));
             $cached = rtrim($cached, "\r\n") . PHP_EOL;
             return $cached;
         }
         clearstatcache();
         touch($cache_file);
         $cache = curl_init();
         curl_setopt($cache, CURLOPT_URL, $url);
         curl_setopt($cache, CURLOPT_TIMEOUT, 15);
         curl_setopt($cache, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($cache, CURLOPT_USERAGENT, 'Transformr/' . $this->version . '  (' . $this->path . '; ' . $this->admin . ')');
         if ($cache_exists) {
             curl_setopt($cache, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
             curl_setopt($cache, CURLOPT_TIMEVALUE, filemtime($cache_file));
         }
         $content = curl_exec($cache);
         // insert fullstop so tidy does not clean empty span or span with just a space
         $content = trim(preg_replace('/<\\s*span(.*?)>\\s<\\/\\s*?span[^>\\w]*?>/', '<span$1>.$2</span>', $content));
         $content = trim(preg_replace('/<\\s*span(.*?)><\\/\\s*?span[^>\\w]*?>/', '<span$1>.</span>', $content));
         $status = curl_getinfo($cache, CURLINFO_HTTP_CODE);
         curl_close($cache);
         if ($cache_exists && $status == 304) {
             $cached = implode('', file($cache_file));
             $cached = rtrim($cached, "\r\n") . PHP_EOL;
             return $cached;
         } else {
             if (!($file_name = @fopen($cache_file, 'w'))) {
                 die('Could not open ' . $cache_file);
             } else {
                 fwrite($file_name, html_convert_entities($content));
                 @fclose($file_name);
             }
         }
         chmod($cache_file, 0644);
         return $content;
     }
 }
Example #4
0
    public static function populate(CCD $base, SimpleXMLELement $xml)
    {
        $component = $xml->addChild('component');
        $section = $component->addChild('section');
        $templateId = $section->addChild('templateId');
        $templateId->addAttribute('root', '2.16.840.1.113883.3.88.11.83.103');
        $templateId->addAttribute('assigningAuthorityName', 'HITSP/C83');
        $templateId = $section->addChild('templateId');
        $templateId->addAttribute('root', '1.3.6.1.4.1.19376.1.5.3.1.3.6');
        $templateId->addAttribute('assigningAuthorityName', 'IHE PCC');
        $templateId = $section->addChild('templateId');
        $templateId->addAttribute('root', '2.16.840.1.113883.10.20.1.11');
        $templateId->addAttribute('assigningAuthorityName', 'HL7 CCD');
        // <!-- Problem section template -->
        $code = $section->addChild('code');
        $code->addAttribute('code', '11450-4');
        $code->addAttribute('codeSystem', '2.16.840.1.113883.6.1');
        $code->addAttribute('codeSystemName', 'LOINC');
        $code->addAttribute('displayName', 'Problem list');
        $section->addChild('title', 'Problems');
        $icd9Rows = array();
        $snomedRows = array();
        $rows = array('ICD-9' => array(), 'SNOMED' => array());
        foreach ($base->problemLists as $problem) {
            $code = html_convert_entities($problem->code);
            $row = array('code' => $code, 'problem' => html_convert_entities($problem->codeTextShort), 'date' => date('M d, Y', strtotime($problem->dateOfOnset)), 'status' => html_convert_entities($problem->status));
            if (strpos($code, '.') !== false) {
                $rows['ICD-9'][] = $row;
            } else {
                $rows['SNOMED'][] = $row;
            }
        }
        $text = $section->addChild('text');
        if ($rows) {
            foreach ($rows as $key => $values) {
                $table = $text->addChild('table');
                $thead = $table->addChild('thead');
                $tr = $thead->addChild('tr');
                $tr->addChild('th', $key . ' Code');
                $tr->addChild('th', 'Problem');
                $tr->addChild('th', 'Date Diagnosed');
                $tr->addChild('th', 'Problem Status');
                $tbody = $table->addChild('tbody');
                foreach ($values as $row) {
                    $tr = $tbody->addChild('tr');
                    $tr->addChild('td', $row['code']);
                    $tr->addChild('td', $row['problem']);
                    $tr->addChild('td', $row['date']);
                    $tr->addChild('td', $row['status']);
                }
            }
        }
        foreach ($base->problemLists as $problem) {
            $entry = '<act classCode="ACT" moodCode="EVN">
				<templateId root="2.16.840.1.113883.3.88.11.83.7" assigningAuthorityName="HITSP C83"/>
				<templateId root="2.16.840.1.113883.10.20.1.27" assigningAuthorityName="CCD"/>
				<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.5.1" assigningAuthorityName="IHE PCC"/>
				<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.5.2" assigningAuthorityName="IHE PCC"/>
				<!-- Problem act template -->
				<id root="' . NSDR::create_guid() . '"/>
				<code nullFlavor="NA"/>
				<statusCode code="active"/>
				<effectiveTime>
					<low nullFlavor="UNK"/>
				</effectiveTime>
				<performer typeCode="PRF">
					<time>
						<low nullFlavor="UNK"/>
					</time>
					<assignedEntity>
						<id extension="PseudoMD-' . $problem->providerId . '" root="2.16.840.1.113883.3.72.5.2"/>
						<addr/>
						<telecom/>
					</assignedEntity>
				</performer>
				<entryRelationship typeCode="SUBJ" inversionInd="false">
					<observation classCode="OBS" moodCode="EVN">
						<templateId root="2.16.840.1.113883.10.20.1.28" assigningAuthorityName="CCD"/>
						<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.5" assigningAuthorityName="IHE PCC"/>
						<!--Problem observation template -->
						<id root="' . NSDR::create_guid() . '"/>
						<code displayName="Condition" code="64572001" codeSystemName="SNOMED-CT" codeSystem="2.16.840.1.113883.6.96"/>
						<text>
							<reference value="#CondID-' . $problem->providerId . '"/>
						</text>
						<statusCode code="completed"/>
						<effectiveTime>
							<low nullFlavor="UNK"/>
							<high nullFlavor="UNK"/>
						</effectiveTime>
						<value xsi:type="CD" displayName="' . html_convert_entities($problem->codeTextShort) . '" code="233604007" codeSystemName="SNOMED" codeSystem="2.16.840.1.113883.6.96"/>
						<entryRelationship typeCode="REFR">
							<observation classCode="OBS" moodCode="EVN">
								<templateId root="2.16.840.1.113883.10.20.1.50"/>
								<!-- Problem status observation template -->
								<code code="33999-4" codeSystem="2.16.840.1.113883.6.1" displayName="Status"/>
								<statusCode code="completed"/>
								<value xsi:type="CE" code="413322009" codeSystem="2.16.840.1.113883.6.96" displayName="' . html_convert_entities($problem->status) . '"/>
							</observation>
						</entryRelationship>
					</observation>
				</entryRelationship>
			</act>';
            $entry = $section->addChild('entry', $entry);
            $entry->addAttribute('typeCode', 'DRIV');
        }
    }
Example #5
0
    public static function populate(CCD $base, SimpleXMLElement $xml)
    {
        $component = $xml->addChild('component');
        $section = $component->addChild('section');
        $templateId = $section->addChild('templateId');
        $templateId->addAttribute('root', '2.16.840.1.113883.3.88.11.83.102');
        $templateId->addAttribute('assigningAuthorityName', 'HITSP/C83');
        $templateId = $section->addChild('templateId');
        $templateId->addAttribute('root', '1.3.6.1.4.1.19376.1.5.3.1.3.13');
        $templateId->addAttribute('assigningAuthorityName', 'IHE PCC');
        $templateId = $section->addChild('templateId');
        $templateId->addAttribute('root', '2.16.840.1.113883.10.20.1.2');
        $templateId->addAttribute('assigningAuthorityName', 'HL7 CCD');
        // <!--Allergies/Reactions section template-->
        $code = $section->addChild('code');
        $code->addAttribute('code', '48765-2');
        $code->addAttribute('codeSystem', '2.16.840.1.113883.6.1');
        $code->addAttribute('codeSystemName', 'LOINC');
        $code->addAttribute('displayName', 'Allergies');
        $section->addChild('title', 'Allergies and Adverse Reactions');
        $enumeration = new Enumeration();
        $listSymptoms = array();
        $enumeration->populateByEnumerationName(PatientAllergy::ENUM_SYMPTOM_PARENT_NAME);
        $enumerationsClosure = new EnumerationsClosure();
        $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
        foreach ($enumerationIterator as $enum) {
            $listSymptoms[$enum->key] = $enum->name;
        }
        $filters = array('patientId' => $base->patient->personId);
        $base->setFiltersDateRange($filters);
        $rows = array();
        $allergies = PatientAllergy::listMedicationAllergies($filters);
        foreach ($allergies as $key => $allergy) {
            $exp = explode(',', $allergy['symptoms']);
            $symptoms = array();
            foreach ($exp as $symp) {
                $symptoms[] = isset($listSymptoms[$symp]) ? $listSymptoms[$symp] : '';
            }
            $reactionType = $allergy['reactionType'];
            if (!strlen($reactionType) > 0) {
                $reactionType = 'Unknown';
            }
            $active = (int) $allergy['active'] ? 'Active' : 'Inactive';
            $snomed = '';
            $row = array();
            $row['type'] = $reactionType;
            //'Drug Allergy';
            if ($reactionType == 'Specific Drug Allergy') {
                $snomed = '416098002';
            }
            $row['snomed'] = $snomed;
            $row['substance'] = html_convert_entities($allergy['causativeAgent']);
            $row['rxnorm'] = html_convert_entities($allergy['rxnorm_cuid']);
            $row['reaction'] = array('id' => 'ReactionID-' . $key, 'value' => html_convert_entities(implode(', ', $symptoms)));
            $row['date'] = date('M d, Y', strtotime($allergy['dateTimeReaction']));
            $row['status'] = html_convert_entities($active);
            $rows[] = $row;
        }
        /*
        -**SNOMED Allergy Type Code** (note from NIST: "The SNOMED Allergy Type Code is required by HITSP/C83, which is a component of the HITSP/C32 implementation guide specified by ONC in the Final Rule")
        -**Medication/Agent Allergy** (including medication/agent allergy and associated RxNorm code)
        */
        $text = $section->addChild('text');
        if ($rows) {
            $table = $text->addChild('table');
            $thead = $table->addChild('thead');
            $tr = $thead->addChild('tr');
            $tr->addChild('th', 'Type');
            $tr->addChild('th', 'Drug allergy SNOMED code');
            $tr->addChild('th', 'Substance');
            $tr->addChild('th', 'Substance RxNorm code');
            $tr->addChild('th', 'Reaction');
            $tr->addChild('th', 'Date Identified');
            $tr->addChild('th', 'Status');
            $tbody = $table->addChild('tbody');
            foreach ($rows as $row) {
                $tr = $tbody->addChild('tr');
                $tr->addChild('td', $row['type']);
                $tr->addChild('td', $row['snomed']);
                $tr->addChild('td', $row['substance']);
                $tr->addChild('td', $row['rxnorm']);
                $td = $tr->addChild('td', $row['reaction']['value']);
                $td->addAttribute('ID', $row['reaction']['id']);
                $tr->addChild('td', $row['date']);
                $tr->addChild('td', $row['status']);
            }
        }
        foreach ($allergies as $allergy) {
            $type = $allergy['reactionType'];
            if (!strlen($type) > 0) {
                $type = 'Unknown';
            }
            $substance = html_convert_entities($allergy['causativeAgent']);
            $exp = explode(',', $allergy['symptoms']);
            $symptoms = array();
            foreach ($exp as $symp) {
                $symptoms[] = isset($listSymptoms[$symp]) ? $listSymptoms[$symp] : '';
            }
            $reaction = '';
            if ($symptoms) {
                $reaction = html_convert_entities(implode(', ', $symptoms));
            }
            $status = 'Inactive';
            $statusCode = 'completed';
            $effectiveTimeHigh = '<high nullFlavor="UNK"/>';
            if ((int) $allergy['active']) {
                $status = 'Active';
                $statusCode = 'active';
                $effectiveTimeHigh = '';
            }
            $status = (int) $allergy['active'] ? 'Active' : 'Inactive';
            // STATUS CODES: active, suspended, aborted, completed
            $statusCode = (int) $allergy['active'] ? 'active' : 'completed';
            $entry = '<act classCode="ACT" moodCode="EVN">
				<templateId root="2.16.840.1.113883.3.88.11.83.6" assigningAuthorityName="HITSP C83"/>
				<templateId root="2.16.840.1.113883.10.20.1.27" assigningAuthorityName="CCD"/>
				<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.5.1" assigningAuthorityName="IHE PCC"/>
				<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.5.3" assigningAuthorityName="IHE PCC"/>
				<id root="' . NSDR::create_guid() . '"/>
				<code nullFlavor="NA"/>
				<statusCode code="' . $statusCode . '"/>
				<effectiveTime>
					<low nullFlavor="UNK"/>' . $effectiveTimeHigh . '
				</effectiveTime>
				<entryRelationship typeCode="SUBJ" inversionInd="false">
					<observation classCode="OBS" moodCode="EVN">
						<templateId root="2.16.840.1.113883.10.20.1.18" assigningAuthorityName="CCD"/>
						<templateId root="2.16.840.1.113883.10.20.1.28" assigningAuthorityName="CCD"/>
						<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.5" assigningAuthorityName="IHE PCC"/>
						<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.6" assigningAuthorityName="IHE PCC"/>
						<id root="' . NSDR::create_guid() . '"/>
						<code code="416098002" codeSystem="2.16.840.1.113883.6.96" displayName="drug allergy" codeSystemName="SNOMED CT" />
						<text>
							<reference value="PtrToValueInSectionText"/>
						</text>
						<statusCode code="completed"/>
						<effectiveTime>
							<low nullFlavor="UNK"/>
						</effectiveTime>
						<value xsi:type="CD"/>
						<participant typeCode="CSM">
							<participantRole classCode="MANU">
								<addr/>
								<telecom/>
								<playingEntity classCode="MMAT">
									<code code="70618" codeSystem="2.16.840.1.113883.6.88" displayName="' . $substance . '">
										<originalText>
											<reference value="PointrToSectionText"/>
										</originalText>
									</code>
									<name>' . $substance . '</name>
								</playingEntity>
							</participantRole>';
            if ($reaction != '' && false) {
                $entry .= '
							<entryRelationship typeCode="MFST" inversionInd="true">
								<observation classCode="OBS" moodCode="EVN">
									<templateId root="2.16.840.1.113883.10.20.1.54" assigningAuthorityName="CCD"/>
									<!--Reaction observation template -->
									<code code="ASSERTION" codeSystem="2.16.840.1.113883.5.4"/>
									<text/>
									<statusCode code="completed"/>
									<value xsi:type="CD" code="247472004" codeSystem="2.16.840.1.113883.6.96" displayName="' . $reaction . '"/>
									<entryRelationship typeCode="SUBJ">
										<observation classCode="OBS" moodCode="EVN">
											<templateId root="2.16.840.1.113883.10.20.1.55" assigningAuthorityName="CCD"/>
											<code code="SEV" displayName="Severity" codeSystemName="HL7 ActCode" codeSystem="2.16.840.1.113883.5.4"/>
											<text>Required by HITSP C-83</text>
											<statusCode code="completed"/>
											<value xsi:type="CE" displayName="moderate" code="6736007" codeSystemName="SNOMED" codeSystem="2.16.840.1.113883.6.96"/>
										</observation>
									</entryRelationship>
								</observation>
							</entryRelationship>';
            }
            $entry .= '
							<!--<entryRelationship typeCode="REFR">
								<observation classCode="OBS" moodCode="EVN">
									<templateId root="2.16.840.1.113883.10.20.1.39"/>
									<code code="33999-4" codeSystem="2.16.840.1.113883.6.1" displayName="Status"/>
									<statusCode code="completed"/>
									<value xsi:type="CE" code="55561003" codeSystem="2.16.840.1.113883.6.96" displayName="' . $status . '"/>
								</observation>
							</entryRelationship>-->
						</participant>
					</observation>
				</entryRelationship>
			</act>';
            $entry = $section->addChild('entry', $entry);
            $entry->addAttribute('typeCode', 'DRIV');
        }
    }
Example #6
0
    public static function populate(CCD $base, SimpleXMLElement $xml)
    {
        $component = $xml->addChild('component');
        $section = $component->addChild('section');
        $templateId = $section->addChild('templateId');
        $templateId->addAttribute('root', '2.16.840.1.113883.3.88.11.83.122');
        $templateId->addAttribute('assigningAuthorityName', 'HITSP/C83');
        $templateId = $section->addChild('templateId');
        $templateId->addAttribute('root', '1.3.6.1.4.1.19376.1.5.3.1.3.28');
        $templateId->addAttribute('assigningAuthorityName', 'IHE PCC');
        // <!--Diagnostic Results section template-->
        $code = $section->addChild('code');
        $code->addAttribute('code', '30954-2');
        $code->addAttribute('codeSystem', '2.16.840.1.113883.6.1');
        $code->addAttribute('codeSystemName', 'LOINC');
        $code->addAttribute('displayName', 'Results');
        $section->addChild('title', 'Diagnostic Results');
        $rows = array();
        foreach ($base->labResults as $orderId => $value) {
            foreach ($value['results'] as $lab) {
                $rows[] = array('identifier' => html_convert_entities($lab->identifier), 'description' => html_convert_entities($lab->description), 'result' => html_convert_entities($lab->value . ' ' . $lab->units), 'abnormalFlag' => html_convert_entities($lab->abnormalFlag), 'date' => date('M d, Y', strtotime($lab->observationTime)));
            }
        }
        $text = $section->addChild('text');
        if ($rows) {
            $table = $text->addChild('table');
            $thead = $table->addChild('thead');
            $tr = $thead->addChild('tr');
            $tr->addChild('th', 'LOINC Code');
            $tr->addChild('th', 'Test');
            $tr->addChild('th', 'Result');
            $tr->addChild('th', 'Abnormal Flag');
            $tr->addChild('th', 'Date Performed');
            $tbody = $table->addChild('tbody');
            foreach ($rows as $row) {
                $tr = $tbody->addChild('tr');
                $tr->addChild('td', $row['identifier']);
                $tr->addChild('td', $row['description']);
                $tr->addChild('td', $row['result']);
                $tr->addChild('td', $row['abnormalFlag']);
                $tr->addChild('td', $row['date']);
            }
        }
        foreach ($base->labResults as $orderId => $value) {
            $orderLabTest = $value['orderLabTest'];
            $labTest = $value['labTest'];
            $results = $value['results'];
            $entry = '<organizer classCode="BATTERY" moodCode="EVN">
				<templateId root="2.16.840.1.113883.10.20.1.32"/>
				<!--Result organizer template -->
				<id root="' . NSDR::create_guid() . '"/>
				<code code="43789009" codeSystem="2.16.840.1.113883.6.96" displayName="' . html_convert_entities($labTest->service) . '"/>
				<statusCode code="completed"/>
				<effectiveTime value="' . date('YmdHi', strtotime($orderLabTest->dateCollection)) . '"/>
				<component>
					<procedure classCode="PROC" moodCode="EVN">
						<templateId root="2.16.840.1.113883.3.88.11.83.17" assigningAuthorityName="HITSP C83"/>
						<templateId root="2.16.840.1.113883.10.20.1.29" assigningAuthorityName="CCD"/>
						<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.19" assigningAuthorityName="IHE PCC"/>
						<id/>
						<code code="43789009" codeSystem="2.16.840.1.113883.6.96" displayName="' . html_convert_entities($labTest->service) . '">
							<originalText>' . html_convert_entities($orderLabTest->order->orderText) . '<reference value="Ptr to text  in parent Section"/>
							</originalText>
						</code>
						<text>' . html_convert_entities($orderLabTest->order->orderText) . '<reference value="Ptr to text  in parent Section"/>
						</text>
						<statusCode code="completed"/>
						<effectiveTime value="' . date('YmdHi', strtotime($orderLabTest->dateCollection)) . '"/>
						<performer>
							<assignedEntity>
								<id extension="PseudoMD-' . $orderLabTest->order->providerId . '" root="2.16.840.1.113883.3.72.5.2"/>
								<addr>See documentationOf in Header</addr>
								<telecom/>
							</assignedEntity>
						</performer>
					</procedure>
				</component>';
            foreach ($results as $result) {
                $referenceRange = '';
                if (strlen($result->referenceRange) > 0) {
                    $referenceRange = '
						<referenceRange>
							<observationRange>
								<text>' . html_convert_entities($result->referenceRange) . '</text>
							</observationRange>
						</referenceRange>';
                }
                if (is_numeric($result->value)) {
                    $resultValue = '<value xsi:type="PQ" value="' . html_convert_entities($result->value) . '" unit="' . html_convert_entities($result->units) . '"/>';
                } else {
                    $resultValue = '<value xsi:type="ST">' . html_convert_entities($result->value) . '</value>';
                }
                $entry .= '
				<component>
					<observation classCode="OBS" moodCode="EVN">
						<templateId root="2.16.840.1.113883.3.88.11.83.15" assigningAuthorityName="HITSP C83"/>
						<templateId root="2.16.840.1.113883.10.20.1.31" assigningAuthorityName="CCD"/>
						<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.13" assigningAuthorityName="IHE PCC"/>
						<templateId root="2.16.840.1.113883.3.88.11.83.15.1"/>
						<!-- Result observation template -->
						<id root="' . NSDR::create_guid() . '"/>
						<code code="' . html_convert_entities($result->identifier) . '" codeSystem="2.16.840.1.113883.6.1" displayName="' . html_convert_entities($result->description) . '"/>
						<text>
							<reference value="PtrToValueInsectionText"/>
						</text>
						<statusCode code="completed"/>
						<effectiveTime value="' . date('YmdHi', strtotime($result->observationTime)) . '"/>
						' . $resultValue . '
						<interpretationCode code="N" codeSystem="2.16.840.1.113883.5.83"/>
						' . $referenceRange . '
					</observation>
				</component>';
            }
            $entry .= '
				<component>
					<act classCode="ACT" moodCode="EVN">
						<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.4" assigningAuthorityName="IHE PCC"/>
						<id/>
						<code nullFlavor="NA"/>
						<text>
							<reference value="PointerToTextinSection"/>
						</text>
						<reference typeCode="REFR">
							<externalDocument classCode="DOC" moodCode="EVN">
								<id root="REGISTRYOID" extension="SOMEID" assigningAuthorityName="NIST Registry"/>
								<text>http://nist.etc</text>
							</externalDocument>
						</reference>
					</act>
				</component>
			</organizer>';
            $entry = $section->addChild('entry', $entry);
            $entry->addAttribute('typeCode', 'DRIV');
        }
    }
Example #7
0
File: rss.php Project: lmcro/fcms
/**
 * displayFeedAll 
 *
 * Displays RSS 2.0 feed for all updates to the site
 * 
 *  ADDRESSADD      Add address of non-member
 *  ADDRESSEDIT     Edit own address
 *  AVATAR          Change avatar
 *  BOARD           Message board post
 *  CALENDAR        Add date to calendar
 *  DOCS            Added document
 *  GALCATCOM       Commented on category of photos
 *  GALCOM          Commented on photo
 *  GALLERY         Added photo
 *  JOINED          Joined the site (became active)
 *  NEWS            Added family news
 *  NEWSCOM         Commented on family news
 *  POLL            Added poll
 *  POLLCOM         Commented on poll
 *  PRAYERS         Added prayer concern
 *  RECIPES         Added recipe
 *  RECIPECOM       Commented on recipe
 *  STATUS          Added status update
 *  VIDEO           Added video
 *  VIDEOCOM        Commented on video
 *  WHEREISEVERYONE Checked in on foursquare
 * 
 * @author: choc
 * @author: Ryan Haudenschilt <*****@*****.**>
 * 
 * @return  void
 */
function displayFeedAll()
{
    $fcmsError = FCMS_Error::getInstance();
    $fcmsDatabase = Database::getInstance($fcmsError);
    $url = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
    $urlRoot = $url;
    $pos = strrpos($url, "/");
    if ($pos === false) {
        $pos = strrpos($url, "\\");
    }
    if (!($pos === false)) {
        $urlRoot = substr($url, 0, $pos);
    }
    // Get data
    $whatsNewData = getWhatsNewData(30);
    if ($whatsNewData === false) {
        return;
    }
    $output = "<?xml version=\"1.0\"?" . "> \n<rss version=\"2.0\"> \n<channel> \n<title>" . getSiteName() . " - " . T_('What\'s New') . "</title> \n<link>" . $url . "</link> \n<description>" . getSiteName() . " - " . T_('What\'s New') . " " . T_('RSS Feed') . "</description> \n<language>" . T_pgettext('Language Code for this translation', 'lang') . "</language> \n<managingEditor>" . getContactEmail() . "</managingEditor> \n";
    foreach ($whatsNewData as $line) {
        $title = "";
        $link = "";
        $guid = "";
        // Clean the data
        $cId = (int) $line['id'];
        $cId2 = (int) $line['id2'];
        $cUserid = (int) $line['userid'];
        $cTitle = html_convert_entities($line['title']);
        // Add Address
        if ($line['type'] == 'ADDRESSADD') {
            $displayname = getUserDisplayName($cId2);
            $for = getUserDisplayName($cUserid, 2, false);
            $link = 'addressbook.php?address=' . $cId;
            $title = sprintf(T_('%s has added address information for %s.'), $displayname, $for);
        } elseif ($line['type'] == 'ADDRESSEDIT') {
            $displayname = getUserDisplayName($cId2);
            $link = 'addressbook.php?address=' . $cId;
            $title = sprintf(T_('%s has updated his/her address.'), $displayname);
        } elseif ($line['type'] == 'AVATAR') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'profile.php?member=' . $cUserid;
            $title = sprintf(T_('%s has changed his/her picture.'), $displayname);
        } elseif ($line['type'] == 'BOARD') {
            $sql = "SELECT min(`id`) AS id \n                    FROM `fcms_board_posts` \n                    WHERE `thread` = ?";
            $minpost = $fcmsDatabase->getRow($sql, $cId2);
            if ($minpost === false) {
                // error will be logged, but not displayed
                continue;
            }
            $userName = getUserDisplayName($cUserid);
            $subject = $cTitle;
            $link = "messageboard.php?thread=" . $cId2;
            $pos = strpos($subject, '#ANOUNCE#');
            if ($pos !== false) {
                $subject = substr($subject, 9, strlen($subject) - 9);
            }
            if ($cId == $minpost['id']) {
                $title = sprintf(T_('%s started the new thread %s.'), $userName, $subject);
            } else {
                $title = sprintf(T_('%s replied to %s.'), $userName, $subject);
            }
        } elseif ($line['type'] == 'CALENDAR') {
            // TODO
            // copy from calendar_class
            $displayname = getUserDisplayName($cUserid);
            $date_date = gmdate(T_('m-d-y'), strtotime($cId2));
            $date_date2 = gmdate(T_('F j, Y'), strtotime($cId2));
            $link = 'calendar.php?year=' . gmdate('Y', strtotime($date_date2)) . '&amp;month=' . gmdate('m', strtotime($date_date2)) . '&amp;day=' . gmdate('d', strtotime($date_date2));
            $title = sprintf(T_('%s has added a new Calendar entry on %s for %s.'), $displayname, $date_date, $cTitle);
        } elseif ($line['type'] == 'DOCS') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'documents.php';
            $title = sprintf(T_('%s has added a new document (%s).'), $displayname, $cTitle);
        } elseif ($line['type'] == 'GALCATCOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'gallery/index.php?uid' . $cId2 . '&amp;cid=' . (int) $line['id3'];
            $title = sprintf(T_('%s commented on (%s).'), $displayname, $cTitle);
        } elseif ($line['type'] == 'GALCOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'gallery/index.php?uid=0&amp;cid=comments&amp;pid=' . $cId;
            $title = sprintf(T_('%s commented on the following photo:'), $displayname);
        } elseif ($line['type'] == 'GALLERY') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'gallery/index.php?uid=' . $cUserid . '&amp;cid=' . $cId;
            $title = sprintf(T_('%s has added %d new photos to the %s category.'), $displayname, $cId2, $cTitle);
        } elseif ($line['type'] == 'JOINED') {
            $displayname = getUserDisplayName($cUserid);
            $link = "profile.php?member=" . $cUserid;
            $title = sprintf(T_('%s has joined the website.'), $displayname);
        } elseif ($line['type'] == 'NEWS') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'familynews.php?getnews=' . $cUserid . '&amp;newsid=' . $cId;
            $title = sprintf(T_('%s has added %s to his/her Family News.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'NEWSCOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'familynews.php?getnews=' . $cUserid . '&amp;newsid=' . $cId;
            $title = sprintf(T_('%s commented on Family News %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'POLL') {
            $link = 'polls.php?id=' . $cId;
            $title = sprintf(T_('A new Poll (%s) has been added.'), $cTitle);
        } elseif ($line['type'] == 'POLLCOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'polls.php?id=' . $cId;
            $title = sprintf(T_('%s commented on Poll %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'PRAYERS') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'prayers.php';
            $title = sprintf(T_('%s has added a Prayer Concern for %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'RECIPES') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'recipes.php?category=' . $cId2 . '&amp;id=' . $cId;
            $title = sprintf(T_('%s has added the recipe %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'RECIPECOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'recipes.php?category=' . $cId2 . '&amp;id=' . $cId;
            $title = sprintf(T_('%s commented on Recipe %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'STATUS') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'home.php';
            $title = $displayname . ': ' . $cTitle;
        } elseif ($line['type'] == 'VIDEO') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'video.php?u=' . $cUserid . '&amp;id=' . $cId;
            $title = sprintf(T_('%s has added a the video %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'VIDEOCOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'video.php?u=' . $cUserid . '&amp;id=' . $cId;
            $title = sprintf(T_('%s commented on the video %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'WHEREISEVERYONE') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'whereiseveryone.php';
            $title = sprintf(T_('%s visited %s.'), $displayname, $cTitle);
        }
        $output .= "\n<item>\n<title><![CDATA[{$title}]]></title> \n<pubDate>" . gmdate(T_('D, d M Y H:i:s'), strtotime($line['date'])) . " GMT</pubDate> \n<link>{$urlRoot}/{$link}</link> \n<guid isPermaLink=\"false\"><![CDATA[{$urlRoot} {$title} " . gmdate(T_('D, d M Y H:i:s'), strtotime($line['date'])) . "]]></guid> \n</item>";
    }
    $output .= "\n</channel>\n</rss>";
    echo $output;
}