protected function getVitalSignsTemplateKeyValue($vitalSignTemplateId = 1) { return VitalSignTemplate::generateVitalSignsTemplateKeyValue($vitalSignTemplateId); }
public function populateVitalSigns(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.16'); // <!-- Vital signs section template --> $code = $section->addChild('code'); $code->addAttribute('code', '8716-3'); $code->addAttribute('codeSystem', '2.16.840.1.113883.6.1'); $section->addChild('title', 'Vital Signs'); $filters = array('personId' => $this->_patientId); $this->setFiltersDateRange($filters); $iterator = new VitalSignGroupsIterator(); $iterator->setFilter($filters); $headers = array('Date / Time:'); $vitals = array(); foreach ($iterator as $vsGroup) { $headers[$vsGroup->dateTime] = date('M d, Y', strtotime($vsGroup->dateTime)); foreach ($vsGroup->vitalSignValues as $vital) { $vitals[$vital->vital][$vsGroup->dateTime] = $vital; } } $rows = array(); $labelKeyValues = VitalSignTemplate::generateVitalSignsTemplateKeyValue(); foreach ($labelKeyValues as $key => $value) { if (!isset($vitals[$key])) { continue; } $row = array('value' => html_convert_entities($value), 'data' => array()); foreach ($vitals[$key] as $dateTime => $vital) { $row['data'][] = html_convert_entities($vital->value . ' ' . $vital->units); } $rows[] = $row; } $text = $section->addChild('text'); if ($rows) { $table = $text->addChild('table'); $thead = $table->addChild('thead'); $tr = $thead->addChild('tr'); $align = 'right'; foreach ($headers as $header) { $th = $tr->addChild('th', $header); $th->addAttribute('align', $align); $align = 'left'; } $tbody = $table->addChild('tbody'); foreach ($rows as $row) { $tr = $tbody->addChild('tr'); $tr->addChild('th', $row['value']); foreach ($row['data'] as $data) { $tr->addChild('td', $data); } } } }
protected function getVitalSignsTemplateKeyValue($vitalSignTemplateId = 1) { $vitalSignTemplate = new VitalSignTemplate(); $vitalSignTemplate->vitalSignTemplateId = $vitalSignTemplateId; $vitalSignTemplate->populate(); $template = simplexml_load_string($vitalSignTemplate->template); $vitals = array(); foreach ($template as $vital) { $title = (string) $vital->attributes()->title; $vitals[$title] = (string) $vital->attributes()->label; } return $vitals; }