public function listAction()
 {
     $showAll = (int) $this->_getParam('showAll');
     $patientId = (int) $this->_getParam('patientId');
     $rows = array();
     $patientNote = new PatientNote();
     $patientNoteIterator = $patientNote->getIterator();
     $filters = array();
     $filters['patient_id'] = $patientId;
     $filters['posting'] = 1;
     if (!$showAll) {
         $filters['active'] = 1;
     }
     $patientNoteIterator->setFilters($filters);
     foreach ($patientNoteIterator as $note) {
         $tmp = array();
         $tmp['id'] = $note->patientNoteId;
         $tmp['data'][] = $note->priority;
         $tmp['data'][] = $note->noteDate;
         $tmp['data'][] = $note->user->username;
         $tmp['data'][] = $note->reason;
         $tmp['data'][] = $note->note;
         $tmp['data'][] = $note->active;
         $tmp['data'][] = $note->active;
         $rows[] = $tmp;
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $rows));
 }
 public function listAction()
 {
     $showAll = (int) $this->_getParam('showAll');
     $patientId = (int) $this->_getParam('patientId');
     $rows = array();
     $patientNote = new PatientNote();
     $patientNoteIterator = $patientNote->getIterator();
     $filters = array();
     $filters['patient_id'] = $patientId;
     $filters['posting'] = 1;
     if (!$showAll) {
         $filters['active'] = 1;
     }
     $patientNoteIterator->setFilters($filters);
     $reasons = array();
     $enumeration = new Enumeration();
     $enumeration->populateByEnumerationName(PatientNote::ENUM_REASON_PARENT_NAME);
     $enumerationsClosure = new EnumerationsClosure();
     $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
     $ctr = 0;
     foreach ($enumerationIterator as $enum) {
         // since data type of patient_note.reason is tinyint we simply use the counter as id
         $reasons[$ctr++] = $enum->name;
     }
     foreach ($patientNoteIterator as $note) {
         $tmp = array();
         $tmp['id'] = $note->patientNoteId;
         $tmp['data'][] = $note->priority;
         $tmp['data'][] = $note->noteDate;
         $tmp['data'][] = $note->user->username;
         $tmp['data'][] = isset($reasons[$note->reason]) ? $reasons[$note->reason] : '';
         $tmp['data'][] = $note->note;
         $tmp['data'][] = $note->active ? __('No') : __('Yes');
         $tmp['data'][] = $note->active;
         $rows[] = $tmp;
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $rows));
 }
 public function patientAction()
 {
     $personId = (int) $this->_getParam('personId');
     $this->view->reasons = PatientNote::listReasons();
     if (!isset($this->_session->active)) {
         $this->_session->active = 1;
     }
     if (!isset($this->_session->inactive)) {
         $this->_session->inactive = 1;
     }
     $this->view->active = $this->_session->active;
     $this->view->inactive = $this->_session->inactive;
     $this->render('patient');
 }
 public function listNotesAction()
 {
     $patientId = (int) $this->_getParam('patientId');
     $rows = array();
     $patientNote = new PatientNote();
     $patientNoteIterator = $patientNote->getIterator();
     $filters = array();
     $filters['patient_id'] = $patientId;
     $filters['active'] = 1;
     $filters['posting'] = 0;
     $patientNoteIterator->setFilters($filters);
     $reasons = $this->_getReasons();
     foreach ($patientNoteIterator as $note) {
         $tmp = array();
         $tmp['id'] = $note->patient_note_id;
         $tmp['data'][] = $note->priority;
         $tmp['data'][] = $note->note_date;
         $tmp['data'][] = $note->user->username;
         $tmp['data'][] = isset($reasons[$note->reason]) ? $reasons[$note->reason] : '';
         $tmp['data'][] = $note->note;
         $tmp['data'][] = $note->active ? __('No') : __('Yes');
         $rows[] = $tmp;
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $rows));
 }
 public function _editAppointment(array $params, $action = 'new')
 {
     $appointmentId = isset($params['appointmentId']) ? (int) $params['appointmentId'] : 0;
     $appointment = new Appointment();
     $appointment->appointmentId = $appointmentId;
     $date = isset($params['date']) ? $params['date'] : '';
     if ($appointmentId > 0 && $appointment->populate()) {
         $filter = $this->getCurrentDisplayFilter();
         $start = explode(' ', date('Y-m-d H:i', strtotime($appointment->start)));
         $date = $start[0];
         $appointment->start = $start[1];
         $appointment->end = date('H:i', strtotime($appointment->end));
         $recordNumber = $appointment->patient->record_number;
         $patientName = $appointment->patient->displayName;
         $this->view->patient = "{$patientName} #{$recordNumber} PID:{$appointment->patient->person_id}";
     } else {
         $start = isset($params['start']) ? $params['start'] : self::FILTER_TIME_START;
         $appointment->start = $start;
         $appointment->end = date('H:i', strtotime('+1 hour', strtotime($start)));
         $appointment->providerId = isset($params['providerId']) ? (int) $params['providerId'] : 0;
         $appointment->roomId = isset($params['roomId']) ? (int) $params['roomId'] : 0;
     }
     $this->view->date = $date;
     $form = new WebVista_Form(array('name' => $action . '-appointment'));
     $form->setAction(Zend_Registry::get('baseUrl') . 'calendar.raw/process-' . $action . '-appointment');
     $form->loadORM($appointment, 'Appointment');
     $form->setWindow('windowAppointmentId');
     $this->view->form = $form;
     $this->view->reasons = PatientNote::listReasons();
     $phones = array();
     $phone = new PhoneNumber();
     $phoneIterator = $phone->getIteratorByPersonId($appointment->patientId);
     foreach ($phoneIterator as $row) {
         $phones[] = $row->number;
     }
     $this->view->phones = $phones;
     $appointmentTemplate = new AppointmentTemplate();
     $this->view->appointmentReasons = $appointmentTemplate->getAppointmentReasons();
     $this->view->appointment = $appointment;
     $this->view->callbackId = $this->_getParam('callbackId', '');
     $this->render('appointment');
 }
 public function _setActivePatient($personId, $visitId)
 {
     if (!$personId > 0) {
         return;
     }
     $memcache = Zend_Registry::get('memcache');
     $patient = new Patient();
     $patient->personId = (int) $personId;
     $patient->populate();
     $patient->person->populate();
     $this->_patient = $patient;
     $this->view->patient = $this->_patient;
     $mostRecentRaw = $memcache->get('mostRecent');
     $currentUserId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
     $personId = $patient->personId;
     $teamId = $patient->teamId;
     if ($mostRecentRaw === false) {
         $mostRecent = array();
     } else {
         $mostRecent = unserialize($mostRecentRaw);
     }
     if (!array_key_exists($currentUserId, $mostRecent)) {
         $mostRecent[$currentUserId] = array();
     }
     if (array_key_exists($personId, $mostRecent[$currentUserId])) {
         unset($mostRecent[$currentUserId][$personId]);
     }
     $name = $patient->person->last_name . ', ' . $patient->person->first_name . ' ' . substr($patient->person->middle_name, 0, 1) . ' #' . $patient->record_number;
     $mostRecent[$currentUserId][$patient->personId] = array('name' => $name, 'teamId' => $teamId);
     $memcache->set('mostRecent', serialize($mostRecent));
     if (strlen($patient->teamId) > 0) {
         $name = TeamMember::ENUM_PARENT_NAME;
         $enumeration = new Enumeration();
         $enumeration->populateByEnumerationName($name);
         $enumerationsClosure = new EnumerationsClosure();
         $rowset = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
         $patientEnumerationId = 0;
         foreach ($rowset as $row) {
             if ($patient->teamId == $row->key) {
                 $patientEnumerationId = $row->enumerationId;
                 break;
             }
         }
         if ($patientEnumerationId !== 0) {
             $this->view->team = TeamMember::generateTeamTree($patientEnumerationId);
         }
     }
     // POSTINGS
     $allergies = array();
     $patientAllergy = new PatientAllergy();
     $patientAllergyIterator = $patientAllergy->getIteratorByPatient($personId);
     foreach ($patientAllergyIterator as $allergy) {
         if ($allergy->noKnownAllergies) {
             continue;
         }
         $allergies[] = $allergy->toArray();
     }
     $this->view->allergies = $allergies;
     $notes = array();
     $patientNote = new PatientNote();
     $patientNoteIterator = $patientNote->getIterator();
     $filters = array();
     $filters['patient_id'] = $personId;
     $filters['active'] = 1;
     $filters['posting'] = 1;
     $patientNoteIterator->setFilters($filters);
     foreach ($patientNoteIterator as $note) {
         $notes[] = $note->toArray();
     }
     $this->view->notes = $notes;
     //REMINDERS
     $ctr = 0;
     $hsa = new HealthStatusAlert();
     $hsaIterator = $hsa->getIteratorByStatusWithPatientId('active', $personId);
     foreach ($hsaIterator as $row) {
         $ctr++;
     }
     if ($ctr > 0) {
         $this->view->reminders = $ctr;
     }
     // VISITS
     //$this->_visit = null;
     if (!$visitId > 0) {
         return;
     }
     $visit = new Visit();
     $visit->encounter_id = (int) $visitId;
     $visit->populate();
     $this->_visit = $visit;
     $this->view->visit = $this->_visit;
 }
 public function processDeleteAction()
 {
     $id = (int) $this->_getParam('id');
     $orm = $this->_getParam('orm');
     $obj = null;
     switch ($orm) {
         case 'patientNote':
             $obj = new PatientNote();
             $obj->patientNoteId = $id;
             break;
     }
     $ret = false;
     if ($obj !== null) {
         $obj->setPersistMode(WebVista_Model_ORM::DELETE);
         $obj->persist();
         $ret = true;
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($ret);
 }