/**
  * Edit clinical notes template, this must be called using AJAX
  */
 public function editTemplateAction()
 {
     $clinicalNoteTemplateId = (int) $this->_getParam('clinicalNoteTemplateId');
     $cnTemplate = new ClinicalNoteTemplate();
     if ($clinicalNoteTemplateId > 0) {
         $cnTemplate->clinicalNoteTemplateId = $clinicalNoteTemplateId;
         $cnTemplate->populate();
         $definitions = array();
         $cndIterator = new ClinicalNoteDefinitionIterator();
         $filters = array();
         $filters['clinicalNoteTemplateId'] = $clinicalNoteTemplateId;
         $cndIterator->setFilters($filters);
         $this->view->definitions = $cndIterator;
     }
     $objForm = new WebVista_Form(array('name' => 'cnTemplate'));
     $objForm->setAction(Zend_Registry::get('baseUrl') . "clinical-notes-manager.raw/process-edit-template");
     $objForm->loadORM($cnTemplate, "cnTemplate");
     $objForm->setWindow('windowEditTemplate');
     $this->view->form = $objForm;
     $this->render();
 }
 public function indexAction()
 {
     $personId = (int) $this->_getParam('personId');
     $clinicalNoteId = (int) $this->_getParam('clinicalNoteId');
     trigger_error('ttpid: ' . $personId, E_USER_NOTICE);
     $cn = new ClinicalNote();
     $cn->clinicalNoteId = (int) $clinicalNoteId;
     $cn->populate();
     $templateId = $cn->clinicalNoteTemplateId;
     $cnTemplate = new ClinicalNoteTemplate();
     $cnTemplate->clinicalNoteTemplateId = (int) $templateId;
     $cnTemplate->populate();
     $xml = simplexml_load_string($cnTemplate->template);
     $objective = '';
     foreach ($xml as $question) {
         foreach ($question as $key => $item) {
             if ($key != "dataPoint") {
                 continue;
             }
             $namespace = (string) $item->attributes()->template;
             // extract the nsdr: format
             preg_match('/{nsdr:(.*)}/', $namespace, $matches);
             if (isset($matches[1])) {
                 $namespace = str_replace('[selectedPatientId]', $personId, $matches[1]);
                 $result = NSDR::populate($namespace);
                 $objective .= $result[$namespace];
             }
         }
     }
     $this->view->objective = $objective;
     $filter = array('personId' => $personId);
     $pl = new ProblemList();
     $pli = $pl->getIterator();
     $pli->setFilters($filter);
     $this->view->problemListIterator = $pli;
 }
Exemplo n.º 3
0
 public static function upgradeClinicalNote()
 {
     /* NOTE: take output file and
     		# cat upnote.sql | sort -n | uniq > upnote2.sql
     		For it to run quickly all the fields used in the join need to be indexed, otherwise 5 seconds per row give or take */
     set_time_limit(0);
     $db = Zend_Registry::get('dbAdapter');
     $genericData = new self();
     $sql = "\n\t\tSELECT genericData.name, clinicalNoteDefinitions.clinicalNoteTemplateId\n\t\t\tFROM `genericData`\n\t\t\tINNER JOIN clinicalNotes ON clinicalNotes.clinicalNoteId = genericData.objectId\n\t\t\tINNER JOIN clinicalNoteDefinitions on clinicalNoteDefinitions.clinicalNoteDefinitionId = clinicalNotes.clinicalNoteDefinitionId\n\t\t\tGROUP BY genericData.name, clinicalNoteDefinitions.clinicalNoteTemplateId";
     $res = $db->query($sql);
     while (($row = $res->fetch()) !== false) {
         $cn = new ClinicalNoteTemplate();
         $cn->clinicalNoteTemplateId = (int) $row['clinicalNoteTemplateId'];
         if (!$cn->populate()) {
             $error = 'Error populating clinical note ' . $cn->clinicalNoteId;
             trigger_error($error);
             continue;
         }
         try {
             $xml = new SimpleXMLElement($cn->template);
             foreach ($xml as $question) {
                 foreach ($question as $key => $item) {
                     if ($key != 'dataPoint') {
                         continue;
                     }
                     $namespace = (string) $item->attributes()->namespace;
                     $html = preg_replace('/[-\\.]/', '_', $namespace);
                     $output = 'UPDATE ' . $genericData->_table . ' INNER JOIN clinicalNotes ON clinicalNotes.clinicalNoteId = genericData.objectId INNER JOIN clinicalNoteDefinitions on clinicalNoteDefinitions.clinicalNoteDefinitionId = clinicalNotes.clinicalNoteDefinitionId SET `name`=' . $db->quote($namespace) . ' WHERE `name`=' . $db->quote($html) . ' AND objectClass=\'ClinicalNote\' AND clinicalNoteDefinitions.clinicalNoteTemplateId=' . $cn->clinicalNoteTemplateId . ";\n";
                     file_put_contents('/tmp/upnote.sql', $output, FILE_APPEND);
                     echo ".";
                 }
             }
         } catch (Exception $e) {
             $error = 'Error parsing template for clinical note ' . $cn->clinicalNoteId . ' template ' . $templateId;
             trigger_error($error);
             continue;
         }
     }
 }