public function executeEdit(sfWebRequest $request)
 {
     if ($request->isMethod('POST')) {
         $report = LabReportPeer::retrieveByPk($this->getRequestParameter('report_id'));
         $report->setDescription($this->getRequestParameter('description'));
         $report->save();
         $this->getUser()->setFlash('SUCCESS_MESSAGE', 'Lab Report editted Successfully.');
         $this->redirect('LabReport/list');
     } else {
         print_r($this->report = LabReportPeer::retrieveByPk(Utility::DecryptQueryString($this->getRequestParameter('report'))));
     }
 }
 public function executeDelete(sfWebRequest $request)
 {
     $designation = DesignationPeer::retrieveByPk(Utility::DecryptQueryString($request->getParameter('id')));
     if ($designation) {
         $designation->setStatus(Constant::RECORD_STATUS_DELETED);
         if ($designation->save()) {
             $this->getUser()->setFlash('SUCCESS_MESSAGE', Constant::RECORD_STATUS_DELETED_SUCCESSFULLY);
         } else {
             $this->getUser()->setFlash('ERROR_MESSAGE', Constant::DB_ERROR);
         }
     } else {
         $this->getUser()->setFlash('ERROR_MESSAGE', Constant::INVALID_REQUEST);
     }
     $this->redirect('Designation/list');
 }
 public function executeCheckup(sfWebRequest $request)
 {
     if ($request->isMethod('POST')) {
         $visit_id = $this->getRequestParameter('visit_id');
         $patient_id = $this->getRequestParameter('patient_id');
         $meds = $this->getRequestParameter('med');
         $dose = $this->getRequestParameter('dose');
         $quantity = $this->getRequestParameter('quantity');
         $tests = $this->getRequestParameter('test');
         $total_cost = 0;
         //Saving Medicines for Current Visit
         foreach ($meds as $i => $med) {
             $pharma = PharmaPeer::retrieveByPk($med[0]);
             $med_price = $pharma->getPrice();
             $visit_med = new VisitMedicine();
             $visit_med->setPatientId($patient_id);
             $visit_med->setVisitId($visit_id);
             $visit_med->setPharmaId($med[0]);
             $visit_med->setDosageId($dose[$i]);
             $visit_med->setQuantity($quantity[$i]);
             $visit_med->setPrice($quantity[$i] * $med_price);
             $visit_med->save();
             $total_cost = $quantity[$i] * $med_price + $total_cost;
         }
         //Saving Lab Tests for Current Visit
         foreach ($tests as $j => $test) {
             $lab_test = LabTestPeer::retrieveByPk($test[0]);
             $test_price = $lab_test->getPrice();
             $visit_test = new LabReport();
             $visit_test->setPatientId($patient_id);
             $visit_test->setVisitId($visit_id);
             $visit_test->setLabTestId($test[0]);
             $visit_test->setPrice($test_price);
             $visit_test->setStatus(Constant::RECORD_STATUS_ACTIVE);
             $visit_test->save();
             $total_cost = $test_price + $total_cost;
         }
         //Saving Current Visit
         $visit = VisitPeer::retrieveByPk($visit_id);
         $doc_id = $visit->getDoctorId();
         $doc = EmployeePeer::retrieveByPk($doc_id);
         $doc_fee = $doc->getVisitFee();
         $total_cost = $total_cost + $doc_fee;
         $visit->setBp($this->getRequestParameter('bp'));
         $visit->setPulse($this->getRequestParameter('pulse'));
         $visit->setTemp($this->getRequestParameter('temp'));
         $visit->setDiet($this->getRequestParameter('diet'));
         $visit->setDescription($this->getRequestParameter('description'));
         $visit->setFee($total_cost);
         $visit->setFeePaid(Constant::VISIT_FEE_NOT_PAID);
         $visit->setStatus(Constant::VISIT_DONE);
         $visit->save();
         $this->getUser()->setFlash('SUCCESS_MESSAGE', 'Patient Visit saves Successfully');
         $this->redirect('Visit/docList');
     } else {
         $patient_id = Utility::DecryptQueryString($request->getParameter('patient'));
         $visit_id = Utility::DecryptQueryString($request->getParameter('visit'));
         $this->patient = PatientPeer::retrieveByPk($patient_id);
         $this->visit = VisitPeer::retrieveByPk($visit_id);
         $c = new Criteria();
         $c->add(PharmaPeer::STATUS, Constant::RECORD_STATUS_ACTIVE);
         $c->addAscendingOrderByColumn(PharmaPeer::NAME);
         $this->medicines = PharmaPeer::doSelect($c);
         $d = new Criteria();
         $d->add(LabTestPeer::STATUS, Constant::RECORD_STATUS_ACTIVE);
         $d->addAscendingOrderByColumn(LabTestPeer::TITLE);
         $this->tests = LabTestPeer::doSelect($d);
     }
 }
 public function executeVisitDetail(sfWebRequest $request)
 {
     $this->visit = VisitPeer::retrieveByPk(Utility::DecryptQueryString($request->getParameter('visit')));
     $visit = VisitPeer::retrieveByPk(Utility::DecryptQueryString($request->getParameter('visit')));
     $visit_id = $visit->getId();
     $c = new Criteria();
     //$c->add(LabReportPeer::STATUS, Constant::RECORD_STATUS_DELETED, Criteria::NOT_EQUAL);
     $c->add(LabReportPeer::VISIT_ID, $visit_id);
     $this->tests = LabReportPeer::doSelect($c);
     $d = new Criteria();
     //$d->add(VisitMedicinePeer::STATUS, Constant::RECORD_STATUS_DELETED, Criteria::NOT_EQUAL);
     $d->add(VisitMedicinePeer::VISIT_ID, $visit_id);
     $this->medicines = VisitMedicinePeer::doSelect($d);
 }
 public function executeDetail(sfWebRequest $request)
 {
     $this->patient = PatientPeer::retrieveByPk(Utility::DecryptQueryString($request->getParameter('patient')));
 }
 public function executeGiveCredential(sfWebRequest $request)
 {
     if ($request->isMethod('Post')) {
         $password = md5($this->getRequestParameter('password'));
         $user = new User();
         $user->setEmployeeId($this->getRequestParameter('employee_id'));
         $user->setUser($this->getRequestParameter('user_name'));
         $user->setPassword($password);
         $user->setRoleId($this->getRequestParameter('role_id'));
         $user->setStatus(Constant::RECORD_STATUS_ACTIVE);
         $user->save();
         $this->getUser()->setFlash('SUCCESS_MESSAGE', 'Credentials Assigned Successfully.');
         $this->redirect('Employee/detail?employee=' . Utility::EncryptQueryString($this->getRequestParameter('employee_id')));
     } else {
         $this->employee = EmployeePeer::retrieveByPk(Utility::DecryptQueryString($request->getParameter('employee')));
     }
 }