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);
 }
 public function processDeleteAction()
 {
     $personId = (int) $this->_getParam("personId");
     $type = $this->_getParam("type");
     $id = (int) $this->_getParam("id");
     $obj = null;
     switch ($type) {
         case 'address':
             $obj = new Address();
             break;
         case 'phone':
             $obj = new PhoneNumber();
             break;
         case 'note':
             $obj = new PatientNote();
             break;
         default:
             break;
     }
     $retVal = false;
     if ($obj !== null && $id > 0) {
         foreach ($obj->_primaryKeys as $k) {
             $obj->{$k} = $id;
         }
         $obj->setPersistMode(WebVista_Model_ORM::DELETE);
         $obj->persist();
         $retVal = true;
     }
     if ($retVal) {
         $data = true;
     } else {
         $data = array('error' => __('There was an error attempting to delete the selected record.'));
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
예제 #3
0
 public function processEditByFieldAction()
 {
     $personId = (int) $this->_getParam("personId");
     $type = $this->_getParam("type");
     $id = (int) $this->_getParam("id");
     $field = $this->_getParam("field");
     $value = $this->_getParam("value");
     $obj = null;
     switch ($type) {
         case 'address':
             $obj = new Address();
             $obj->person_id = $personId;
             if (!$id > 0) {
                 $obj->active = 1;
             }
             break;
         case 'phone':
             $obj = new PhoneNumber();
             $obj->person_id = $personId;
             if (!$id > 0) {
                 $obj->active = 1;
             }
             break;
         case 'note':
             $obj = new PatientNote();
             $obj->patient_id = $personId;
             if ($id === 0) {
                 // defaults for new note
                 $obj->note_date = date('Y-m-d H:i:s');
                 $obj->user_id = (int) Zend_Auth::getInstance()->getIdentity()->personId;
                 $obj->priority = 5;
                 $obj->active = 1;
             }
             break;
         default:
             break;
     }
     $retVal = false;
     if ($obj !== null && in_array($field, $obj->ormFields())) {
         if ($id > 0) {
             foreach ($obj->_primaryKeys as $k) {
                 $obj->{$k} = $id;
             }
             $obj->populate();
         }
         $obj->{$field} = $value;
         $obj->persist();
         $retVal = true;
     }
     if ($retVal) {
         $data = true;
     } else {
         $data = array('error' => __('There was an error attempting to update the selected record.'));
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }