public function processSetVisitTypePrimaryProviderAction() { $providerId = (int) $this->_getParam('id'); $visitId = (int) $this->_getParam('visitId'); $personId = (int) $this->_getParam('personId'); $isPrimary = (int) $this->_getParam('isPrimary'); $data = false; $patientVisitType = new PatientVisitType(); $patientVisitType->patientId = $personId; $patientVisitType->visitId = $visitId; $patientVisitType->providerId = (int) $providerId; $patientVisitType->populateWithIds(); if ($patientVisitType->resetPrimaryProvider()) { $data = true; } $patientVisitType->isPrimary = $isPrimary; $patientVisitType->persist(); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }
public function processPatientVisitTypesAction() { $patientId = (int) $this->_getParam('patientId'); $visitTypes = $this->_getParam('visitTypes'); if ($patientId > 0) { $patientVisitTypeIterator = new PatientVisitTypeIterator(); $patientVisitTypeIterator->setFilters(array('patientId' => $patientId)); $existingVisitTypes = $patientVisitTypeIterator->toArray('providerId', 'patientId'); if (is_array($visitTypes)) { foreach ($visitTypes as $providerId => $visitType) { if (isset($existingVisitTypes[$providerId])) { unset($existingVisitTypes[$providerId]); } $visitType['providerId'] = $providerId; $visitType['patientId'] = $patientId; $patientVisitType = new PatientVisitType(); $patientVisitType->populateWithArray($visitType); $patientVisitType->persist(); } } // delete un-used records foreach ($existingVisitTypes as $providerId => $patientId) { $patientVisitType = new PatientVisitType(); $patientVisitType->providerId = $providerId; $patientVisitType->patientId = $patientId; $patientVisitType->setPersistMode(WebVista_Model_ORM::DELETE); $patientVisitType->persist(); } } $data = array(); $data['msg'] = __('Record saved successfully'); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }