public function flowSheetTemplateAction()
 {
     $personId = (int) $this->_getParam('personId');
     $patient = new Patient();
     $patient->personId = $personId;
     $patient->populate();
     $vitalSignIter = new VitalSignGroupsIterator();
     $vitalSignIter->setFilter(array("personId" => $personId));
     $xmlData = PdfController::toXML($patient, 'Patient', null);
     $xmlData .= "<VitalSignGroups>";
     $loop = 0;
     foreach ($vitalSignIter as $vitalGroup) {
         $xmlData .= PdfController::toXML($vitalGroup, 'VitalSignGroup', null);
         if ($loop > 5) {
             exit;
         }
         $loop++;
     }
     $xmlData .= "</VitalSignGroups>";
     //header('Content-type: text/xml;');
     //echo $xmlData;exit;
     $this->_forward('pdf-merge-attachment', 'pdf', null, array('attachmentReferenceId' => '5', 'xmlData' => $xmlData));
 }
 public function listVitalSignsAction()
 {
     $personId = (int) $this->_getParam('personId');
     $vitalSignIter = new VitalSignGroupsIterator();
     $vitalSignIter->setFilter(array("personId" => $personId));
     //normally can just use ORMIterator->toJsonArray but vital sign groups are a special case with a nested array
     $vitalsJsonArray = array();
     foreach ($vitalSignIter as $vitalSignGroup) {
         foreach ($vitalSignGroup->getVitalSignValues() as $vitalValue) {
             $tmpArray = array();
             $tmpArray['id'] = $vitalValue->vitalSignValueId;
             $tmpArray['data'] = array();
             $tmpArray['data'][] = $vitalSignGroup->dateTime;
             $tmpArray['data'][] = $vitalValue->vital;
             $tmpArray['data'][] = $vitalValue->value;
             $tmpArray['data'][] = $vitalValue->units;
             $vitalsJsonArray[] = $tmpArray;
         }
     }
     //$vitals = $vitalSignIter->toJsonArray('vitalSignGroupId',array('dateTime','vital','value','units'));
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $vitalsJsonArray));
 }
예제 #3
0
 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);
             }
         }
     }
 }